Parent item has a scale transform set, the child item's font is automatically scaled. How can I drawText with orignal font (without scaling from parent) at the same location?
Thanks
Parent item has a scale transform set, the child item's font is automatically scaled. How can I drawText with orignal font (without scaling from parent) at the same location?
Thanks
Last edited by lni; 29th January 2009 at 20:34.
Anyone help pls?
Use QGraphicsItem::ItemIgnoresTransformations
Try this and it is not desirable. The text is now drawn in the wrong place...
I can use QPen::setCosmetic, I think QFont should have similar property. When doing transform, most of the time we want to keep the font size unchanged...
By the way, setScalable or setTransformable is much more intuitive...
This is terrible, I have spent 6 hours on this and found nothing!
All I want is not to rotate or scale my font. QGraphicsItem::ItemIgnoresTransformations does ignore the scaling and rotating, but it also lose the location.
Can some one please give an example?
If you set the bounding rect of the text item correctly, you won't lose position, just anchor the (0,0) point to the position where you want it to be.
I am trying to print the grid number along axis, such as 0, 10, 20, 30.... This GridNumberTextItem is derived from QGraphicsItem, so here is what I do
Qt Code:
GridNumberTextItem::GridNumberTextItem(...) { } GridNumberTextItem::paint(...) { float val = 0; while ( val <= 100 ) { val += 10; // assuming step is 10 } }To copy to clipboard, switch view to plain text mode
In doing so, I lose transform for "pos", so the text is drawn in wrong place. The parent item has a scaling transform. How can I fix this problem? Thanks!
I'm not sure why you use some "pos" inside your paint routine. You should anchor the text item to the value you want it to represent. Then you can make it ignore transformations and rely purely on setPos().
We were talking about fonts here so I more meant the labels describing points. And yes, I meant make each label a separate item.
I'm not exactly sure what you are doing - it is probably some kind of graph or canvas and a ruler. Have you thought about making the ruler a separate widget?
Bookmarks