[Qt-interest] Finding the displayed width of rich text

Gordon Schumacher gordon at rebit.com
Sun Dec 20 07:09:08 CET 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
 
John Posner wrote:
> I need to know the size of the displayed fraction, in order to select
> the optimal point-size for the label. QFontMetrics.width() does the job
> for the plain-text label, but for the rich-text label, it returns the
> size of the 25-character string, not the size of the 3-character
> superscript-and-subscript string.
>
> I found a workaround: find the size of the QLabel widget itself, which
> is just big enough to accommodate the rich-text label. But I'm looking
> for other solutions (because I want to fiddle with the label's size).
> Can anyone provide advice?

Not advice so much, but a "me too": I spent a fair chunk of time
trying to figure out how to make this work, and failed utterly.  I
can't even use your workaround, since I'm living in QGraphicsView
land, so there's no widget that it's wrapped in.

I can, however, point you at one gotcha I discovered:
http://bugreports.qt.nokia.com/browse/QTBUG-6144

I'm definitely gonna keep an eye on this thread, though - if you
figure it out, let me know!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.12 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
 
iEYEARECAAYFAkstv4QACgkQ2yRp4mXKHF14DQCfZAETUWSpjIM7XCAw1Qp2f0Uw
1RIAni/avO+M1TbsbfIA5Pq+kaiAZknG
=7+8/
-----END PGP SIGNATURE-----




More information about the Qt-interest-old mailing list