Trolltech Home | Qt4-preview-feedback Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt4-preview-feedback Archive, April 2007
QGraphicsTextItem - some remarks


Message 1 in thread

Hello,

Editable and Movable - cannot work together???
Arrows don't change the cursor position
inside the text.
Home and End keys don't work.
Selection can be changed only from mouse (not from keyboard).
Selection sometimes remains on the text, when item is not active.
Ctrl-Z works, but Ctrl-Y doesn't.

Please, consider the example (attached).

Best regards and Happy Easter,
Igor Grivko
#include <QtGui>
#include <QtGui>

int main(int argc, char** argv)
{
  QApplication app(argc, argv);
  
  QMainWindow* pMain = new QMainWindow;
  QGraphicsScene* pScene = new QGraphicsScene;
  QGraphicsView* pView = new QGraphicsView(pScene);

  
  QGraphicsTextItem* pItem = new QGraphicsTextItem(0, pScene);
  pItem->setPlainText("Editable and Movable - cannot work together???\nArrows don't work to change position\ninside the text.\nHome and End keys don't work\nSelection can be changed only from mouse (not from keyboard).\nSelection sometimes remains on the text, when item is not active.\nCtrl-Z works, but Ctrl-Y doesn't.");
  pItem->setTextInteractionFlags(Qt::TextEditable);
  pItem->setFlag(QGraphicsItem::ItemIsMovable);
  pItem->setPos(10, 10);



  pMain->setCentralWidget(pView);
  pMain->show();


  return app.exec();
}

Message 2 in thread

One more remark - when the main window gets the focus it passes the focus to 
the editable GraphicsText - even if the GraphicsText item was not edited 
before. 

So all this little things make GraphicsText impossible to use in "editable" 
mode.

Best regards,
Igor Grivko

9 ÐÐÑÐÐÑ 2007 10:35, Igor Grivko ÐÐÐÐÑÐÐ:
> Hello,
>
> Editable and Movable - cannot work together???
> Arrows don't change the cursor position
> inside the text.
> Home and End keys don't work.
> Selection can be changed only from mouse (not from keyboard).
> Selection sometimes remains on the text, when item is not active.
> Ctrl-Z works, but Ctrl-Y doesn't.
>
> Please, consider the example (attached).
>
> Best regards and Happy Easter,
> Igor Grivko

To unsubscribe - send "unsubscribe" in the subject to qt4-preview-feedback-request@xxxxxxxxxxxxx


Message 3 in thread

On Monday 09 April 2007 08:35:05 Igor Grivko wrote:
> Hello,
>
> Editable and Movable - cannot work together???

Using Qt 4.3 I can move the item by dragging it at its border.

> Arrows don't change the cursor position
> inside the text.
> Home and End keys don't work.
> Selection can be changed only from mouse (not from keyboard).
> Selection sometimes remains on the text, when item is not active.
> Ctrl-Z works, but Ctrl-Y doesn't.

The fact that the Home and End keys don't work is probably a bug, but you
may want to use TextEditorInteraction as text interaction flag instead of just 
TextEditable anyway. This way the text is not only editable but also 
selectable (TextEditorInteraction implies TextEditable as well as 
TextSelectableByKeyboard and TextSelectableByMouse).

Simon

Attachment:

Attachment: pgpnuIbIFEuVg.pgp
Description: PGP signature


Message 4 in thread

9 ÐÐÑÐÐÑ 2007 13:42, Simon Hausmann ÐÐÐÐÑÐÐ:
> On Monday 09 April 2007 08:35:05 Igor Grivko wrote:
> > Hello,
> >
> > Editable and Movable - cannot work together???
>
> Using Qt 4.3 I can move the item by dragging it at its border.

Thanks, I can move it too, but sometimes it is hard to drag it - very thin 
catch area.

>
> > Arrows don't change the cursor position
> > inside the text.
> > Home and End keys don't work.
> > Selection can be changed only from mouse (not from keyboard).
> > Selection sometimes remains on the text, when item is not active.
> > Ctrl-Z works, but Ctrl-Y doesn't.
>
> The fact that the Home and End keys don't work is probably a bug, but you
> may want to use TextEditorInteraction as text interaction flag instead of
> just TextEditable anyway. This way the text is not only editable but also
> selectable (TextEditorInteraction implies TextEditable as well as
> TextSelectableByKeyboard and TextSelectableByMouse).

Thanks, TextEditorInteraction works all right and may be I can use this class 
if it doesn't grab focus from the main window.

And I can redo from popup menu (it appears it TextEditorInteraction mode), but 
Ctrl-Y doesn't work.

>
> Simon

Regards,
Igor Grivko

To unsubscribe - send "unsubscribe" in the subject to qt4-preview-feedback-request@xxxxxxxxxxxxx


Message 5 in thread

On Monday 09 April 2007 13:25:19 Igor Grivko wrote:
[...]
> And I can redo from popup menu (it appears it TextEditorInteraction mode),
> but Ctrl-Y doesn't work.

I guess you are running your application under KDE or GNOME? Unfortunately 
none of those two platforms define Ctrl+Y as standard shortcut for redo :(

http://developer.kde.org/documentation/standards/kde/style/keys/shortcuts.html
http://developer.gnome.org/projects/gup/hig/2.0/input-keyboard.html#standard-shortcuts

Ctrl+Y is a standard shortcut for redo when running your application under 
Windows or Mac OS X though.

Simon

Attachment:

Attachment: pgpytl2QqEqP9.pgp
Description: PGP signature


Message 6 in thread

Hello Simon,

You are right, I am using KDE, and after viewing your link I knew that 
Ctrl-Shift-Z is a standard shortcut for Redo in KDE (and it works for my 
example well !!!).

But in the popup-menu I can see "Redo Ctrl-Y". So I must not believe my eyes? 
Anyhow this popup menu misleads users (and me as well :-( ).

Another problem is that accelerators is catched by MainWindow (if it has the 
same action with the same shortscuts).

See attached files.

Best regards,
Igor Grivko



9 ÐÐÑÐÐÑ 2007 15:40, Simon Hausmann ÐÐÐÐÑÐÐ:
> On Monday 09 April 2007 13:25:19 Igor Grivko wrote:
> [...]
>
> > And I can redo from popup menu (it appears it TextEditorInteraction
> > mode), but Ctrl-Y doesn't work.
>
> I guess you are running your application under KDE or GNOME? Unfortunately
> none of those two platforms define Ctrl+Y as standard shortcut for redo :(
>
> http://developer.kde.org/documentation/standards/kde/style/keys/shortcuts.h
>tml
> http://developer.gnome.org/projects/gup/hig/2.0/input-keyboard.html#standar
>d-shortcuts
>
> Ctrl+Y is a standard shortcut for redo when running your application under
> Windows or Mac OS X though.
>
> Simon
#include <QtGui>
#include <QtGui>
#include "main_window.h"






int main(int argc, char** argv)
{
  QApplication app(argc, argv);
  
  MyMainWindow* pMain = new MyMainWindow;
  QGraphicsScene* pScene = new QGraphicsScene;
  QGraphicsView* pView = new QGraphicsView(pScene);

  
  QGraphicsTextItem* pItem = new QGraphicsTextItem(0, pScene);
  pItem->setPlainText("Editable and Movable - cannot work together???\nArrows don't work to change position\ninside the text.\nHome and End keys don't work\nSelection can be changed only from mouse (not from keyboard).\nSelection sometimes remains on the text, when item is not active.\nCtrl-Z works, but Ctrl-Y doesn't.");
  pItem->setTextInteractionFlags(Qt::TextEditorInteraction);//Qt::TextEditable);
  pItem->setFlag(QGraphicsItem::ItemIsMovable);
  pItem->setPos(10, 10);



  pMain->setCentralWidget(pView);
  pMain->show();


  return app.exec();
}
#ifndef MAIN_WINDOW_H
#ifndef MAIN_WINDOW_H
#define MAIN_WINDOW_H

#include <QMainWindow>

class MyMainWindow : public QMainWindow
{
    Q_OBJECT
public:
  MyMainWindow();
  
  
private slots:
  void undo();
  void redo();

private:
  void createMenu();
  

private:
  QAction* undoAct;
  QAction* redoAct;
  
};

#endif
#include <QtGui>
#include <QtGui>
#include "main_window.h"

MyMainWindow::MyMainWindow()
{
 createMenu();
}


void MyMainWindow::createMenu()
{
  undoAct = new QAction(QIcon(), tr("&Undo"), this);
  undoAct->setShortcut(tr("Ctrl+Z"));
  connect(undoAct, SIGNAL(triggered()), this, SLOT(undo()));

  redoAct = new QAction(QIcon(), tr("&Redo"), this);
  redoAct->setShortcut(tr("Ctrl+Y"));
  connect(redoAct, SIGNAL(triggered()), this, SLOT(redo()));
  
  QMenu* editMenu = menuBar()->addMenu(tr("&Edit"));
  editMenu->addAction(undoAct);
  editMenu->addAction(redoAct);
}



void MyMainWindow::undo() 
{
  qDebug() << "undo";
  QMessageBox::warning(this, "", "Undo!");
}

  
void MyMainWindow::redo() 
{
  qDebug() << "redo";
  QMessageBox::warning(this, "", "Redo!");
}

Message 7 in thread

Igor Grivko wrote:
> Hello Simon,
> You are right, I am using KDE, and after viewing your link I knew that
> Ctrl-Shift-Z is a standard shortcut for Redo in KDE (and it works for my
> example well !!!).
> But in the popup-menu I can see "Redo Ctrl-Y". So I must not believe my
> eyes? Anyhow this popup menu misleads users (and me as well :-( ).
> Another problem is that accelerators is catched by MainWindow (if it has
> the same action with the same shortscuts).
> See attached files.

Hi, Igor. You're right, something's wrong with this menu :-). We'll look at
it asap.

Beyond that, are your QGraphicsTextItem problems resolved?

Andreas

-- 
 [ signature omitted ] 

Message 8 in thread

Hi Andreas,

There are some problems, you may see them from my last example.

1. After returning focus to the MainWindow it immediately passes it to the 
last editable QGraphicsTextItem (even if it was not edited before).
2. Accelerators may be catched from MainWindow before they get 
QGraphicsTextItem in edit mode.
3. The catch area for moving editable item is too thin - it is a work for men 
with steel nerves :-) (and strong hands :-) ).
4. Selection area remains on the editable item - just click on it, select some 
word and click out of it.

So it works, but with some problems, and now I prefer to create my own class.

Best regards and Happy Easter,
Igor Grivko

> Hi, Igor. You're right, something's wrong with this menu :-). We'll look at
> it asap.
>
> Beyond that, are your QGraphicsTextItem problems resolved?
>
> Andreas

To unsubscribe - send "unsubscribe" in the subject to qt4-preview-feedback-request@xxxxxxxxxxxxx