Hi,

I got precision problems with the selection in a QGraphicsScene. It is quiet simple to reproduce. Here is my code...

Qt Code:
  1. //----------------------------------------------------------------------------
  2. // Includes
  3. //----------------------------------------------------------------------------
  4.  
  5. #include <QApplication>
  6. #include <QGraphicsView>
  7. #include <QGraphicsRectItem>
  8. #include <QHBoxLayout>
  9.  
  10. //----------------------------------------------------------------------------
  11.  
  12. class MyFooView : public QGraphicsView
  13. {
  14. public:
  15. MyFooView(QWidget* parent = NULL) :
  16. QGraphicsView(parent)
  17. {
  18. setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
  19. }
  20. MyFooView(QGraphicsScene* scene, QWidget* parent = NULL) :
  21. QGraphicsView(scene, parent)
  22. {
  23. setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
  24. scale(20.0, 20.0);
  25. }
  26. ~MyFooView(void)
  27. {
  28. }
  29. };
  30.  
  31. int main(int argv, char **args)
  32. {
  33. QApplication app(argv, args);
  34.  
  35. scene->setSceneRect(QRectF(0, 0, 5000, 5000));
  36.  
  37. MyFooView* view = new MyFooView(scene);
  38.  
  39. QGraphicsRectItem* dummy = new QGraphicsRectItem(50.0, 50.0, 30.0, 30.0);
  40. dummy->setBrush(QBrush(Qt::red));
  41. dummy->setAcceptHoverEvents(true);
  42. dummy->setFlag(QGraphicsItem::ItemIsSelectable, true);
  43. dummy->setFlag(QGraphicsItem::ItemIgnoresTransformations, true);
  44. scene->addItem(dummy);
  45.  
  46. view->centerOn(0.0, 0.0);
  47.  
  48. l->addWidget(view);
  49.  
  50. QWidget* w = new QWidget();
  51. w->setLayout(l);
  52. w->show();
  53.  
  54. return app.exec();
  55. }
To copy to clipboard, switch view to plain text mode 

Run the program. For me it is possible to select the rect item a bit above and left of its shape. Can someone confirm and tell me how to solve it?

Best regards,
Marcus