[Qt-interest] QGraphicsWidget that provides word-wrapping label?

Paul Drummond paul.drummond at iode.co.uk
Thu Aug 12 17:47:22 CEST 2010


Hi,

I am trying to implement a word-wrapping label as a QGraphicsWidget that
calculates its own bounding rect based on the size of the text/font but I
must be misunderstanding something because I can't find the solution.

I noticed that there is a version of drawText that returns (in a parameter)
the "actual" bounding rect that the full text requires.

But what do I do with it?  I have tried calling
setGeometry(actualBoundingRect) directly inside the paint method after
calling drawText (even thought it feels wrong!) and it kinds of works.  The
graphics widget does resize to the size of the text but the enclosing layout
doesn't seem to notice as none of the other widgets in the layout move to
accommodate.

I am clearly doing something very wrong!  Can anyone point me in the right
direction here please?

Thanks,
Paul Drummond
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100812/03579d2e/attachment.html 


More information about the Qt-interest-old mailing list