Results 1 to 3 of 3

Thread: Cann't move movable items on custom graphics view

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2007
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    2

    Default Cann't move movable items on custom graphics view

    Hi,
    I'm drawing QGraphicsEllipseItem on QGraphicsScene viewed through MyGraphicsView subclassed from QGraphicsView (mouse events are reimplemented to handle zoom in/out by right-click-drag-release).
    The item is supposed to be movable (setFlag(QGraphicsItem::ItemIsMovable,true)) but I cannot move it.

    I'm attaching simple code to illustrate the problem.

    What am I missing?
    Wojtek
    Attached Files Attached Files

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

    Default Re: Cann't move movable items on custom graphics view

    You must call the base class implementation in your re-implemented mouse event handlers to let the view know about received events.

    Qt Code:
    1. void MyGraphicsView::mousePressEvent( QMouseEvent *e )
    2. {
    3. ...
    4. QGraphicsView::mousePressEvent(e); // <---
    5. ...
    6. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    wojtekw (3rd March 2008)

  4. #3
    Join Date
    Feb 2007
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    2

    Default Re: Cann't move movable items on custom graphics view

    Big thanks jpn!
    wojtek

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.