Results 1 to 3 of 3

Thread: contextMenuEvent in QGraphicsItem

  1. #1
    Join Date
    Jul 2007
    Location
    Romania, Bucarest
    Posts
    12
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question contextMenuEvent in QGraphicsItem

    how can i reimplement contextMenuEvent tu have a menu with various actions

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: contextMenuEvent in QGraphicsItem

    Qt Code:
    1. void CustomItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
    2. {
    3. QMenu menu;
    4. QAction *removeAction = menu.addAction("Remove");
    5. QAction *markAction = menu.addAction("Mark");
    6. QAction *selectedAction = menu.exec(event->screenPos());
    7. // ...
    8. }
    To copy to clipboard, switch view to plain text mode 
    From assistant.

    Of course, you can create the QMenu somewhere else in your class.

    Regards

  3. #3
    Join Date
    Jul 2007
    Location
    Romania, Bucarest
    Posts
    12
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: contextMenuEvent in QGraphicsItem

    Thencs, problem solv

Similar Threads

  1. Disable default tab behaviour for a QGraphicsItem
    By nmather in forum Qt Programming
    Replies: 3
    Last Post: 13th December 2017, 11:30
  2. destruction of QGraphicsItem
    By killkolor in forum Qt Programming
    Replies: 2
    Last Post: 5th December 2009, 11:31
  3. Deleting a scene from QGraphicsItem mouseEvent
    By JonathanForQT4 in forum Qt Programming
    Replies: 5
    Last Post: 10th April 2007, 12:27
  4. QGraphicsView and contextMenuEvent
    By laurabee in forum Qt Programming
    Replies: 1
    Last Post: 12th October 2006, 23:22
  5. contextMenuEvent has issues since 4.1.3
    By momesana in forum Qt Programming
    Replies: 9
    Last Post: 31st May 2006, 18:27

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.