QGraphicsItem: Transformation bug
I am having a rectangle that is used within a QGraphicsItem. Item is added to a scene and it has a pre-defined transformation, so that it maps the rectangle correctly. It was so far so good:
qDebug() << rect;
qDebug() << transform;
qDebug() << transform.map(rect.topLeft());
qDebug() << transform.map(rect.topRight());
qDebug() << transform.map(rect.bottomRight());
qDebug() << transform.map(rect.bottomLeft());
qDebug() << transform.map(rect);
qDebug() << box.polygon();
qDebug() << box.scenePos();@
QTransform(type=TxProject, 11=8.39145 12=3.651e-16 13=-3.79358e-18 21=-11.232 22=1.24517 23=-0.00673223 31=731.81 32=58.3479 33=0.684533)
QPolygonF(QPointF(1478.33, 101.443) QPointF(2004.32, 101.443) QPointF(2466.86, 495.792) QPointF(1216.62, 495.792) QPointF(1478.33, 101.443) )
QPolygonF(QPointF(34.2629, 5.75334) QPointF(74.7427, 5.75334) QPointF(74.7427, 61.3225) QPointF(34.2629, 61.3225) QPointF(34.2629, 5.75334) )
as expected; everything works fine; both vertices and the item itself are transformed right, that I can check all with map function. This worked fine for at least 40 different transforms.
However, for just another transformation matrix I encountered this interesting result:
QTransform(type=TxProject, 11=-4.51027 12=2.57144e-16 13=-1.00432e-19 21=7.88867 22=0.184078 23=0.00360371 31=-511.257 32=-69.1552 33=-0.353853)
QPolygonF(QPointF(0, 0) )
QPolygonF(QPointF(29.8193, 9.86656) QPointF(59.454, 9.86656) QPointF(59.454, 53.6079) QPointF(29.8193, 53.6079) QPointF(29.8193, 9.86656) )
the vertices are transformed successfully; but the rect item couldn't. It is showing (0, 0) for the transformation.
I thought this must be a bug in the framework, as it transforms a point fine but it just couldn't transform the items (I am also having lots of ellipses, rects couldn't be transformed). But when I try to reproduce I couldn't; it happens only with this matrix.
Since map() doesnt work, item.setTransform() - which I suppose using map() - also doesnt work.
For a clear vision I attached the second matrix (transposed) here: !http://i.imgur.com/7SfJHbU.png()!
What am I doing wrong here ? Precision bug ? 32-bit issues ?
This looks to be purely an issue of QTransform. Putting QGraphicsItem in the title is a bit misleading (and might have caused people not to read this thread, because they feel they cannot contribute to anything QGraphicsItem related).
Anyway, it's hard to tell what's going on at a distance. What system are you testing on? Which Qt version are you using? The best way to find out what's going on quickly would probably be to debug into the map() function where it goes wrong.