Results 1 to 3 of 3

Thread: Re-implementing mouse event handlers while retaining its original functionality??

  1. #1
    Join Date
    Mar 2012
    Posts
    14
    Platforms
    Windows
    Thanks
    1

    Default Re-implementing mouse event handlers while retaining its original functionality??

    Hello I am new to QT programming and have some questions i would like to ask..

    I have implemented my own Graphics Scene and has its mouse event handler re-implemented..

    Problem now is, when i add a new graphics item to the scene and set flag to movable, I am not able to move it..

    If i take away the implemented mouse event handler, I can start moving the graphics item freely again..

    How do I re-implement my mouse handler while retaining its original functionality?

    Thanks alot..

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: Re-implementing mouse event handlers while retaining its original functionality??

    Call the parent class mouse event handler for any action you are not handling differently (standard C++ stuff):
    Qt Code:
    1. void mousePressEvent ( QGraphicsSceneMouseEvent * mouseEvent ) {
    2. if (event is of interest to me) {
    3. //do something with it
    4. // accept() or ignore() the event
    5. }
    6. else
    7. QGraphicsScene::mousePressEvent(mouseEvent);
    8. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Mar 2012
    Posts
    14
    Platforms
    Windows
    Thanks
    1

    Default Re: Re-implementing mouse event handlers while retaining its original functionality??

    nvm guys, i solved it

    Just add this to the end of the implemented functions.. =D

    QGraphicsView::mousePressEvent(e);

Similar Threads

  1. Replies: 26
    Last Post: 7th January 2016, 21:26
  2. Implementing event for Qt Designer MainWindow
    By shadowfax in forum Newbie
    Replies: 8
    Last Post: 6th February 2012, 16:09
  3. Replies: 14
    Last Post: 17th January 2012, 10:01
  4. Replies: 3
    Last Post: 7th January 2012, 09:38
  5. Event handlers for QTableView model / selection model.
    By hickscorp in forum Qt Programming
    Replies: 2
    Last Post: 8th July 2011, 18:57

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
  •  
Qt is a trademark of The Qt Company.