Results 1 to 4 of 4

Thread: QAction on Delete interfering with QGraphicsTextItem

  1. #1

    Default QAction on Delete interfering with QGraphicsTextItem

    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?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QAction on Delete interfering with QGraphicsTextItem

    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...

  3. #3

    Default Re: QAction on Delete interfering with QGraphicsTextItem

    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.

    Qt Code:
    1. deleteAction = new QAction(/*icon,*/ tr("&Delete"), this);
    2. deleteAction->setShortcut( tr("Del") );
    3. connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteItem()));
    To copy to clipboard, switch view to plain text mode 

    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...

    Last edited by jpn; 29th July 2008 at 10:53. Reason: missing [code] tags

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QAction on Delete interfering with QGraphicsTextItem

    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" ,

Similar Threads

  1. c++, placement delete upon exception
    By stinos in forum General Programming
    Replies: 6
    Last Post: 31st October 2006, 15:38

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.