Did you try setting an inverted rectangle (starting from negative vertical values and ending at 0 or starting at positive vertical value and ending at 0 or negative) as the scene rect? This way you wouldn't have to scale anything.
Did you try setting an inverted rectangle (starting from negative vertical values and ending at 0 or starting at positive vertical value and ending at 0 or negative) as the scene rect? This way you wouldn't have to scale anything.
Hey, thanks for that reply. N my apologies for replying back late ...
Well, if I invert the scene rectangle, all my points, lines and polygon shapes drawn on it get inverted too. By scaling the view scale(1,-1) I get what I want, like showing proper coordinates on the screen, except only for QGraphicsPixmapItem and QGraphicsTextItem (They get drawn inverted).
The kludge that I adopted worked for me. I transformed the pixmap used in QGraphicsPixmapItem using QTransform. So now it is shown properly onto the canvas. BUT, if i use QGraphicsItem::ItemIgnoresTransformations flag (To keep the picture from changin when the zoom level is changed), the picture just disappears! I dont know why and I have not been able to solve this issue as well...
Is there something wrong with the coordinate system (s) set for scene, view and/or the items in Qt???![]()
has anyone managed to figure out if there is a good way to rotate/translate the coordinate system so that when drawing angles, zero degrees is up and value increase clockwise instead of zero degrees to the right and values increase counter-clockwise?
I have found the solution.
Use a QGraphicsItemGroup to contain the text items. Use the group to set coords, scales and rotation. The text items ignores the transformations.
For example:
Qt Code:
grp->addToGroup(text); text->setFont(font); text->setPos(0,0); grp->setPos(x,y);To copy to clipboard, switch view to plain text mode
Pay attention that the text item must be added to group before his setting his coordinates, since coordinates of the sub-item are relative to the parent item, BUT when adding the item to the group his coords relative to the scene are preserved.
Hope that helps.
Bookmarks