fmetrics
::fmetrics(QWidget *parent, Qt
::WFlags flags
){
ui.setupUi(this);
qDebug
( QString("%1").
arg(metrics.
width(ui.
label->text
())).
toAscii().
constData() );
qDebug
( QString("%1").
arg(metrics2.
width(ui.
label_2->text
())).
toAscii().
constData() );
}
fmetrics::fmetrics(QWidget *parent, Qt::WFlags flags)
: QDialog(parent, flags)
{
ui.setupUi(this);
QFontMetrics metrics(ui.label->font());
QFontMetrics metrics2(ui.label_2->font());
qDebug( QString("%1").arg(metrics.width(ui.label->text())).toAscii().constData() );
qDebug( QString("%1").arg(metrics2.width(ui.label_2->text())).toAscii().constData() );
}
To copy to clipboard, switch view to plain text mode
label and label_2 are two QLabels with the same font set. One has normal font and the other has a bold font.
I always get a smaller width for the label with normal font. I tried with several fonts.
What font did you use?
Regards
Bookmarks