Details
-
Bug
-
Resolution: Incomplete
-
P3: Somewhat important
-
None
-
4.6.3
-
None
-
Linux debian 2.6.32-5-686 #1 SMP Thu Aug 12 13:38:27 UTC 2010 i686 GNU/Linux
Using Qt version 4.6.3 in /usr/lib
Description
I recently was notified about a bug in of my applications where text was being "cut off" After looking into it it seems that QFontMetrics was returning a slightly smaller than expected value for maxWidth(). Since maxWidth() is documented as "Returns the width of the widest character in the font." I would expect that there is no character where width(ch) > maxWidth(), but in at least one setup it is!
For example, on a Debian 6 system the following code:
#include <QApplication> #include <QFont> #include <QFontMetrics> int main(int argc, char *argv[]) { QApplication app(argc, argv); const QFont f("Monospace", 8); const QFontMetrics metrics(f); qDebug("MAX_WIDTH=%d : X_WIDTH=%d", metrics.maxWidth(), metrics.width('X')); }
outputs:
MAX_WIDTH=6 : X_WIDTH=7
So far I have only been able to produce this issue in a "Debian 6 Testing" VM, so this may be an issue with something the debian folks have done. But at least 3 of my users have experienced this. For now, since I only allow fixed width font's in my custom widget, I am working around this issue by simply using ".width('X')"
The version of Qt is 4.6.3 installed from apt-get.