[Qt-interest] Problem with QFontMetrics boundingRect reducing width

Zeljko zeljko at holobit.net
Sat Jan 29 12:20:03 CET 2011


Zeljko wrote:

> Zeljko wrote:
> 
>> Hi,
>> Just run into this bug with my project:
>> http://bugreports.qt.nokia.com/browse/QTBUG-12950
>> under linux. FC 14 qt-4.7.1-7.
>> 
>> According to commited files, it's probably fixed for all platforms except
>> X11. Anyone can confirm this please ?
> 
> Seem that QFontMetrics boundingRect is ok, but QPainter drawText is not.
> So simple case to reproduce is here
> 
> clip rect is 0, 0, 128, 39.
> rect is 4, 4, 120, 31
> font is current system font (liberation sans, size=9).
> 
> painter.drawText(rect, Qt::AlignLeft || Qt::AlignVCenter || Qt::TextWordWrap,
> tr("Save project\nCtrl + S"));

Correction this code should be (written example after bash scripting :))  :
 painter.drawText(rect, Qt::AlignLeft | Qt::AlignVCenter | Qt::TextWordWrap,
   tr("Save project\nCtrl + S"));



> 
> Draws
> --------
> Save
> project
> ---------
> 
> But should be
> ----------------
> Save project
> Ctrl + S
> ----------------
> 
> Same code works ok with qt-4.6.3, but not with qt-4.7.1 (don't know about
> 4.7.0). Tested on linux (fedora 14), Fedora 13 = qt-4.6.3.
> 
> Problem exists if first line contains < 3 spaces and line feed and flags
> contains Qt::TextWordWrap .
> eg. 'Save project\nCtrls + S' - BAD
> eg. 'Save project with\nCtrls + S' - BAD
> eg. 'Save project with keys\nCtrl + S' GOOD
> 
> Note that without Qt::TextWordWrap everything works fine.
> 
> Anyone can confirm, or I should write complete example and open an issue about
> it ?
> 
> thanks
> 
> zeljko




More information about the Qt-interest-old mailing list