[Qt-interest] Possible Bug in QFontMetrics::boundingRect()

Josiah Bryan jbryan at productiveconcepts.com
Wed Sep 16 21:50:50 CEST 2009


Using the code below, on Linux (FC8), it produces:

     Without Space: 24, With Space: 24

On windows XP, it produces:

     Without Space: 19, With Space: 22

Basically, on linux, QFontMetrics::boundingRect() seems to totally 
ignore the space at the end of the string and return the same string 
width, regardless.

Anyone got any idea whats going on? Is it something I'm doing wrong? Or 
is this a bug in Qt? Or is it a problem with linux/my install/etc?

Thanks!
-josiah

Code:
//--------------------------------------

#include <QtGui/QApplication>
#include <QFont>
#include <QFontMetrics>

int main(int argc, char **argv)
{
	QApplication app(argc, argv);		
	QFont font;
	QFont("Sans-Serif",12);
	QFontMetrics metrics(font);
	QRect textRect1 = metrics.boundingRect("test");
	QRect textRect2 = metrics.boundingRect("test ");
	qDebug("Without Space: %d, With Space: %d", textRect1.width(), 
textRect2.width());
	return -1;
}


//--------------------------------------


-- 

-=-=-=-=-=-=-=-=-=-=-=-=-
Josiah Bryan
Productive Concepts, Inc.
jbryan at pciint.com
(765) 964-6009, ext. 224




More information about the Qt-interest-old mailing list