Results 1 to 11 of 11

Thread: Problems with QGraphicsItem and Overiding methods

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Problems with QGraphicsItem and Overiding methods

    If you override QGraphicsScene mouse event handlers, you must call the base class implementation if you want any item to receive mouse events.
    J-P Nurmi

  2. #2

    Default Re: Problems with QGraphicsItem and Overiding methods

    Quote Originally Posted by jpn View Post
    If you override QGraphicsScene mouse event handlers, you must call the base class implementation if you want any item to receive mouse events.
    how do i do that?
    and where do i do that?

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Problems with QGraphicsItem and Overiding methods

    Qt Code:
    1. void SubClass::virtualFunction()
    2. {
    3. BaseClass::virtualFunction(); // <---
    4. // ...
    5. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  4. #4

    Default Re: Problems with QGraphicsItem and Overiding methods

    where subclass is my subclass of QGraphicsScene
    in this case called BoardModel

    and BaseClass is QGraphicsScene itself?


    and virtualfunction is mouseMoveEvent?

  5. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Problems with QGraphicsItem and Overiding methods

    Yes, exactly. Your reimplementation is called instead of the QGraphicsScene implementation, but the QGraphicsScene implementation is the one who delivers mouse events to the items.
    J-P Nurmi

  6. #6

    Default Re: Problems with QGraphicsItem and Overiding methods

    Quote Originally Posted by jpn View Post
    Yes, exactly. Your reimplementation is called instead of the QGraphicsScene implementation, but the QGraphicsScene implementation is the one who delivers mouse events to the items.
    thank you, it worked. Spent months wondering about that!

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.