Hi,

I need advice - I have 2 problems I cannot solve

I'm using QT4.5.1

Firstly the mouseMoveEvent is not fired when drag mode is RubberBandDrag. Is this expected behavior?
Secondly when setSelectionArea is called, the setSelected function of my QGraphicsItem is not called.

Anyone have any ideas what i am doing wrong??
(have I forgotten to set any flags in my scene/graphicsitems?)
Code is below...

Thanks for any advice


Qt Code:
  1. // MyScene is derived from QGraphicsScene
  2.  
  3. void MyScene::mousePressEvent ( QGraphicsSceneMouseEvent * event )
  4. {
  5. views()[0]->setDragMode(QGraphicsView::RubberBandDrag);
  6. m_rubberbandP1 = event->scenePos().toPoint();
  7.  
  8. QGraphicsScene::mousePressEvent(event);
  9. }
  10.  
  11. void MyScene::mouseMoveEvent ( QGraphicsSceneMouseEvent * event )
  12. {
  13. if (views()[0]->dragMode() == QGraphicsView::RubberBandDrag)
  14. qDebug() << "mouseMoveEvent"; // never displays
  15. QGraphicsScene::mouseMoveEvent(event);
  16. }
  17.  
  18. void MyScene::mouseReleaseEvent ( QGraphicsSceneMouseEvent * event )
  19. {
  20. views()[0]->setDragMode(QGraphicsView::ScrollHandDrag);
  21.  
  22. QRect rect(m_rubberbandP1, event->scenePos().toPoint());
  23. pp.addRect(rect);
  24. setSelectionArea(pp);
  25. QGraphicsScene::mouseReleaseEvent(event);
  26. }
To copy to clipboard, switch view to plain text mode