I have QGraphicsItem that is a bubble with text in it. I need to be able to flip and translate the bubble but I don't want it to scale with the view. This way it is always the same size and readable. Any help would be appreciated.
I have QGraphicsItem that is a bubble with text in it. I need to be able to flip and translate the bubble but I don't want it to scale with the view. This way it is always the same size and readable. Any help would be appreciated.
Setting the QGraphicsItem::ItemIgnoresTransformations flag on the text bubble item should do it.
<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.
The problem with that is the view is inverted and flipped. So my text is backwards and upside down. That fixes the size issue but not the flip/reverse issue.
You should be able to apply a transform to the text bubble item itself to flip / mirror it. Remember that item transformations are local to the coordinates system of the item itself. I don't remember where the origin of the text item is - upper left corner maybe, so you'll need to translate then rotate about x and y and translate back.
<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.
In the paint event of my QGraphicsItem (text bubble) I can translate and flip the bubble, however, the bubble becomes oddly shaped when the parent view is scaled. Is there a way to ignore the parents scale or undo the scale in paint event?
If I use the ignore transforms flag on the text bubble item, it also ignores my flip/translate in the paint event.
Are you setting the transform on the QPainter during the paint event? The ignore transforms flag should only prevent transformations on the -parent- object from being propagated to the -child- that has the flag set. If you look at the documentation, it specifically mentions the case you are talking about - keeping text in the same orientation regardless of what happens to the parent item.If I use the ignore transforms flag on the text bubble item, it also ignores my flip/translate in the paint event.
<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.
WolfByte (12th November 2021)
You are correct. I found the mistake in my code. I was still flipping the text based on the view. After setting the Ignore flag I don't need to flip it because the transform to invert it in the first place never happened. Thank you. Sometimes it takes talking to someone else to find the simple bugs.
d_stranz (12th November 2021)
Bookmarks