Selection precision problems with QGraphicsScene and scaled content?
Hi,
I got precision problems with the selection in a QGraphicsScene. It is quiet simple to reproduce. Here is my code...
Code:
//----------------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------------
#include <QApplication>
#include <QGraphicsView>
#include <QGraphicsRectItem>
#include <QHBoxLayout>
//----------------------------------------------------------------------------
{
public:
MyFooView
(QWidget* parent
= NULL) : {
}
{
scale(20.0, 20.0);
}
~MyFooView(void)
{
}
};
int main(int argv, char **args)
{
scene
->setSceneRect
(QRectF(0,
0,
5000,
5000));
MyFooView* view = new MyFooView(scene);
dummy
->setBrush
(QBrush(Qt
::red));
dummy->setAcceptHoverEvents(true);
scene->addItem(dummy);
view->centerOn(0.0, 0.0);
l->addWidget(view);
w->setLayout(l);
w->show();
return app.exec();
}
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
Re: Selection precision problems with QGraphicsScene and scaled content?
The problem you are seeing could be related to this bug.
https://bugreports.qt-project.org/browse/QTBUG-17985
Re: Selection precision problems with QGraphicsScene and scaled content?
Quote:
Originally Posted by
steno
Thanks a lot. With the proposed fix everything works as expected!