QFont font;
font.setBold(true);
std::cout<<QFontMetrics(font).width("...");
Writed 9.
QFont font;
std::cout<<QFontMetrics(font).width("...");
Writed 12.
Why if font is bold the width is smaller then if font is nobold?
QFont font;
font.setBold(true);
std::cout<<QFontMetrics(font).width("...");
Writed 9.
QFont font;
std::cout<<QFontMetrics(font).width("...");
Writed 12.
Why if font is bold the width is smaller then if font is nobold?
It seems to work OK on my system. Which Qt version and what font do you use?
Qt 4.3
I use only this code
And it is writeQt Code:
QFont font2; std::cout<<QFontMetrics(font2).width("...")<<"\n"; font2.setBold(true); font2.setItalic(true); std::cout<<QFontMetrics(font2).width("...");To copy to clipboard, switch view to plain text mode
12
9
if i don't use font2.setBold(true);
it is write
12
12
I've just tried it on windows, and indeed I got 12 and 9, but if you start Qt Designer and compare two labels (one with normal font and second with bold font), you'll see it's a correct result for the default font.
it is a bug of the Qt?
Qt Code:
{ ui.setupUi(this); }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
No, everything is OK. It's just a property of a font you have used.
ss.png
Yes, with "..." I get the same result.
But with other font families this seems to be OK.
Anyway, I don't see a real problem even with MS Shell Dlg 2, as long as the dimensions are correct( which they are ).
So, there must be a glitch in the font.
Regards
Bookmarks