开发者

Qt QLabel HTML font size fails badly

开发者 https://www.devze.com 2023-03-18 00:16 出处:网络
In my Qt application (uses Qt 4.7.0 from Ubuntu 10.10 Linux repository) i tried to use Qt::RichText QLabels using the following HTML:

In my Qt application (uses Qt 4.7.0 from Ubuntu 10.10 Linux repository) i tried to use Qt::RichText QLabels using the following HTML:

    label_1->setText("<font size=64>size=64</font>");
    label_2->setText("<f开发者_如何学编程ont color=red size=10>size=10</font>");
    label_3->setText("<font color=blue size=14>size=14</font>");

For some reason the font sizes are not set properly. All the widgets get the same font size, one that is larger than the default one but still the wrong one. The font size set for the first widget seems to influence the size that the following widgets will use. Setting only the color attribute leaves the label text in its standard size.

I also tried to reproduce this in the QtDesigner and the same problem happens there.

Setting the text format to Qt::Richtext does not have any effect. And using quotes around the HTML attribute values does not change anything either.

What am I missing?

Qt QLabel HTML font size fails badly


Okay, so font size is supported but have you tried CSS-style font-size:64pt? CSS is better because the size has explicit units.

0

精彩评论

暂无评论...
验证码 换一张
取 消