PDA

View Full Version : QAction on Delete interfering with QGraphicsTextItem



mooreaa
25th July 2008, 00:45
Hello,

I have an GraphicsView object that has an embeded QGraphicsTextItem which is the name of the node. When you click the item you can edit the text name of the node.

I noticed that when I added a QAction at my MainWindow level for deleting objects that it gets triggered even while editing text.

Is there any easy way to work around this? IE make delete behavior normally while editing text but trigger my delete command otherwise?

wysota
26th July 2008, 11:56
Did you set a shortcut for your action? If so, how exactly did you do it? Editing an item shouldn't trigger external actions... if it does, you can temporarily disable the action or disable the shortcut, but it shouldn't come to that...

mooreaa
29th July 2008, 07:33
Hmm i posted a reply a day or two ago I thought but maybe I forgot to hit submit. I'm still having issues with this. Here is how I defined my action in my MainWindow.cpp's createActions() initialization function.


deleteAction = new QAction(/*icon,*/ tr("&Delete"), this);
deleteAction->setShortcut( tr("Del") );
connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteItem()));

Its not specific to the delete key thought. The problem is, even though I am editing the text, the shortcut actions override the text entry. So i tested this by changing the shortcut key to "a" and it prevents me from typing the letter a.

So it looks like i need to disable actions in order to make it work interactively with my text edit item...

:(

aamer4yu
29th July 2008, 07:43
Shortcuts are meant to be trigerred, isnt it ??
You can try 2 things -
1) Disconnect the signal for action while u are in editing mode.
2) Set some other shortcut which u wont use during editing eg - "Ctrl + Del" ,