View Full Version : QString size
^NyAw^
23rd January 2008, 16:56
Hi,
How can I know the size in pixels will a QString be?
For example, a QString having "ERROR" as text, wich will the minimum size that I have to set to the QLabel to ensure that will be displayed?
The text showed into the QLabel will be modified but I know that "ERROR" is the max length word.
Thanks,
jpn
23rd January 2008, 17:02
Well, you can calculate it with QFontMetrics, but there was no need if the label was in a layout.
^NyAw^
23rd January 2008, 17:04
Hi,
but there was no need if the label was in a layout
If the label is in a layout it will be resized as I change the text, ok? So, I don't want it to be resized every time, I want to be the maximum text size.
Will take a look at QFontMetrics. (http://doc.trolltech.com/latest/qfontmetrics.html)
Thanks,
ashukla
24th January 2008, 05:04
If the label is in a layout it will be resized as I change the text, ok? So, I don't want it to be resized every time, I want to be the maximum text size.
Will take a look at QFontMetrics.
You break the layout; if exist for label.
QFontMetrics::QFontMetrics ( const QFont & font )
QFontMetrics::width ( const QString & text, int len = -1 )
QFontMetrics::width ( QChar ch )
The above member of QFontMetrics help you.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.