Results 1 to 10 of 10

Thread: Detecting and reacting to mouse dragging in QGraphicsView?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2009
    Posts
    23
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Detecting and reacting to mouse dragging in QGraphicsView?

    I just realized that I meant to use MouseMoveEvent() instead of DragMoveEvent.

    However, it seems that this event doesn't really detect "dragging" (mouse click down and moving"). Maybe I have to manually manage the dragging event by using clicking, release and move events?

  2. #2
    Join Date
    Oct 2009
    Posts
    23
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Detecting and reacting to mouse dragging in QGraphicsView?

    Ok, I figured out how to detection using the MousePressEvent and MouseReleaseEvent and MouseMove event to do the "detect the mouse is dragging" part, now I need to retrieve the position of the mouse to do image-moving calculations. Does anyone have a snippet of code to do this?

    I have this code currently, but it complains.

    Qt Code:
    1. void mapScene::mouseMoveEvent( QGraphicsSceneMouseEvent * event)
    2. {
    3. debug("I vus here 2!");
    4. prevMousePoint = event->lastPos();
    5. currMousePoint = event->pos();
    6. if(mouseDown)
    7. {
    8.  
    9. // xOffset = event->pos().x() - event->lastPos().x();
    10. //yOffset = 1;
    11. }
    12. }
    To copy to clipboard, switch view to plain text mode 

    Complaint:
    error: invalid use of undefined type `struct QGraphicsSceneMouseEvent'
    error: invalid use of undefined type `struct QGraphicsSceneMouseEvent'
    And it points to the lines where prevMousePoint and currMousePoint are. Both variables are of the type QPointF.

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.