Results 1 to 3 of 3

Thread: QGraphicsProxyWidget and mouseEvents

  1. #1
    Join Date
    Mar 2010
    Location
    Heredia, Costa Rica
    Posts
    257
    Thanks
    24
    Thanked 17 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Question QGraphicsProxyWidget and mouseEvents

    Hi,

    I have a QGraphicsProxyWidget with a button. Even thought I override the mousepress and mouserelease events of the proxy with event->ignore(); The button still receives the event and emits a pressed()

    Any idea why or what do I need to do so so the button ignore the events? This without overriding the events of the button?

    Thanks,
    Carlos.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsProxyWidget and mouseEvents

    I might understood wrong, but I think you want to use accept() not ignore().
    ignore() will progate the event further, you want to stop the event, so I think accept() should be used.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Mar 2010
    Location
    Heredia, Costa Rica
    Posts
    257
    Thanks
    24
    Thanked 17 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsProxyWidget and mouseEvents

    Hi,

    Yes, the accept() works but now I run into another trouble:

    The proxy item is embedded into a QGraphicsPolygonItem So it is Scene->Polygon->Proxy->Button

    I did not override the press/release for the Polygon but I did it for the Proxy. This because I want to move the container (and the proxy inside it like a group) but not allow the user to click on the button. The problem is that with the override in the proxy the container cannot move!

    Code of the proxy:
    Qt Code:
    1. void tnkMatrix::mousePressEvent(QGraphicsSceneMouseEvent *event)
    2. {
    3. event->accept();
    4. }
    5.  
    6. void tnkMatrix::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
    7. {
    8. event->accept();
    9. }
    To copy to clipboard, switch view to plain text mode 

    Any help is much appreciated.

    Thanks,
    Carlos.

Similar Threads

  1. QTableWidget mouseEvents
    By QAir in forum Qt Programming
    Replies: 6
    Last Post: 28th July 2009, 16:11
  2. qwt mouseEvents
    By halberdier83 in forum Qwt
    Replies: 7
    Last Post: 22nd April 2009, 12:37
  3. QGraphicsProxyWidget
    By QbelcorT in forum Qt Programming
    Replies: 0
    Last Post: 29th November 2008, 08:21
  4. how to show fillRect() using mouseEvents??
    By thomasjoy in forum Qt Programming
    Replies: 9
    Last Post: 31st August 2007, 14:30
  5. QGraphicsView mouseEvents...?
    By thill2708 in forum Qt Programming
    Replies: 1
    Last Post: 29th November 2006, 20:20

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.