Results 1 to 2 of 2

Thread: how not ta clear the selection on QGraphicsScene right mouse press event

  1. #1
    Join Date
    Aug 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default how not ta clear the selection on QGraphicsScene right mouse press event

    Hi,

    I'm trying to implement the following behavior in my class that inherit QGraphicsScene.

    I'd like to display a context menu on right click (that part is pretty straightforward) wherever the user clicked on the scene (i.e. even on plain background) but whose content depend on the currently selected items.

    I've reimplemented QGraphicsScene::contextMenuEvent, but in this method, the list of selected items is always empty. This is due to the fact that just before the ContextMenuEvent, there is a MousePressEvent that triggers clearSelection().

    I've looked at the source of QGraphicsScene and it seems to me I can either completely ignore the events by reimplementing mousePressEvent and not forwarding the event to QGraphicsScene (and thus loose all the mouse grabbing support I'd like to keep) or I can accept the selection clearing.

    Is there a possibility I didn't see to keep the mouse grabbing support ben handle selection manually ?

    Regard,
    Julien

  2. #2
    Join Date
    May 2009
    Posts
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how not ta clear the selection on QGraphicsScene right mouse press event


Similar Threads

  1. catch global mouse press event
    By nick85 in forum Newbie
    Replies: 3
    Last Post: 15th June 2011, 13:37
  2. QGraphicsview and mouse press event
    By eva2002 in forum Qt Programming
    Replies: 6
    Last Post: 26th January 2010, 05:04
  3. Mouse press event in a QGraphicsScene
    By Lykurg in forum Qt Programming
    Replies: 3
    Last Post: 19th June 2009, 10:28
  4. Mouse press event detection
    By A.H.M. Mahfuzur Rahman in forum Qt Programming
    Replies: 1
    Last Post: 14th June 2009, 13:08
  5. Checking for key press on mouse event
    By Cruz in forum Newbie
    Replies: 1
    Last Post: 24th January 2009, 18:18

Tags for this Thread

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.