Results 1 to 4 of 4

Thread: ItemIsMovable???

  1. #1

    Default ItemIsMovable???

    Hi,
    I want to move an item, but only if I press the right mousebutton.
    Can somebody tell me how to do this?
    I've tried this:
    Qt Code:
    1. void GraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *e)
    2. {
    3. pos=e->scenePos();
    4. end=e->scenePos();
    5. item = new EllipseItem(pos.x(), pos.y(),10,10);
    6. item2 = new EllipseItem(end.x(), end.y(),10,10);
    7.  
    8. if(e->button() == Qt::LeftButton)
    9. {
    10. if(itemAt(pos))
    11. { QGraphicsScene::mousePressEvent(e); }
    12.  
    13. else
    14. {
    15. addItem(item);
    16. addItem(item2);
    17.  
    18. linie = new LineItem(item,item2);
    19. addItem(linie);
    20. }
    21. }
    22.  
    23. if(e->button() == Qt::RightButton)
    24. {
    25. item->setFlags(QGraphicsItem::ItemIsMovable);
    26. item2->setFlags(QGraphicsItem::ItemIsMovable);
    27. }
    28. //this doesn't works
    29. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    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: ItemIsMovable???

    J-P Nurmi

  3. #3

    Default Re: ItemIsMovable???

    The right button works. But although the items are not movable?!

  4. #4
    Join Date
    Sep 2008
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: ItemIsMovable???

    When you press the right mouse button, two items are created but these aren't added to scene. So the scene does not contain anything to mark with ItemIsMovable flag...

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.