2 Attachment(s)
AddText to QRect on QGraphicsView
I am trying to add text on different Qrects I have plotted on the QGraphicsScene (added to QGraphicsView).
I have enabled horizontal zooming of the scene on mousewheel motion. I could add the text to QGraphicsScene but, when I zoom the scene the Text also gets zoomed.
I want to keep the Text size as it is but the text should shift (along with corresponding QRect ) according to the zooming factor ...
I have attached 2 images here ....Attachment 5920Attachment 5921
any suggestions ??
Re: AddText to QRect on QGraphicsView
Set the ItemIgnoresTransformations flag for your text items.
2 Attachment(s)
Re: AddText to QRect on QGraphicsView
thanx...
I have one more query...
As you know , I have put a text on each QRect..
now,what I want is - >
initially I want only some portion of text to be visible as the QRect is smaller in size..
On zooming horizontally , the text should get completed according to the size of QRect...
How can I get this ?
currently the text is going outside the QRect before zooming....
attaching screenshots ...
Attachment 5952Attachment 5953
2 Attachment(s)
Re: AddText to QRect on QGraphicsView
I could find one method to do this....
using QGraphicsTextItem::setTextWidth();
but the problem is, initially the text is broken into many line which I can't hide...
so the broken text lines show up below the corresponding QRect....
attaching screenshot...!!
Attachment 5960
Attachment 5959
Re: AddText to QRect on QGraphicsView
Use the level-of-detail information that you can query for in the item's paint() routine. Or use QFontMetrics to calculate the elided text based on the real rectangle occupied by the item. Which to choose depends on what you actually want to do.