anbu01
17th August 2016, 13:00
I have two items in my tree model i have small difference in text alignment.Is this caused by the width of the text but i checked the width of text using QFontMetrics::width() but both text are same.
Text1:111601756
Text2:999999996
12075
As from the image you can see there is a slight alignment problem in the second text.
Here is the sample code i tried :-
QFont font("times",24);
QFontMetrics metrics(font);
qDebug() << "Width 1" << metrics.width(QString::number(111111111));
qDebug() << "Width 2" << metrics.width(QString::number(999999999));
Output:
Width 1 153
Width 2 153
I expected Width 2 to be more what is going wrong here.Is the method i am checking is wrong.
Text1:111601756
Text2:999999996
12075
As from the image you can see there is a slight alignment problem in the second text.
Here is the sample code i tried :-
QFont font("times",24);
QFontMetrics metrics(font);
qDebug() << "Width 1" << metrics.width(QString::number(111111111));
qDebug() << "Width 2" << metrics.width(QString::number(999999999));
Output:
Width 1 153
Width 2 153
I expected Width 2 to be more what is going wrong here.Is the method i am checking is wrong.