PDA

View Full Version : boundingRect problems



mefalo
8th December 2010, 10:22
The use of the windows

Use the following code returns wrong value

Well this is the bug?



QFont font("times", 24);
QFontMetrics myFontMetrics(font);
qDebug()<<myFontMetrics.boundingRect(0,0,50,2000,Qt::AlignLe ft | Qt::AlignTop | Qt::TextWordWrap,"123456789012345678901234567890");
//return QRect(0,0 480x36)

wysota
8th December 2010, 10:35
So why is this wrong?

mefalo
8th December 2010, 12:46
Qt::TextWordWrap breaks the text to fit the rectangle.

But the text don't fit the rectangle
Back to the width changed, I think fixed at 50

Lykurg
8th December 2010, 12:55
Qt::TextWordWrap != Qt::TextWrapAnywhere. But the documentation says that you can't use Qt::TextWrapAnywhere with bounding rect. Nevertheless try it.