|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
Setting relative font sizesHi there,
Currently, I have some QLabels with rich text in them, such as "<font size=+1>foo</font>". I'm trying to move this kind of font setting to a style sheet in the .ui, or even set it via QLabel::setStyleSheet, however setting the style sheet to "font-size: larger;" or anything that's not a pixel or point value doesn't work, and I don't know if it's possible to set the size in a relative way (like the +1 that's being used at the moment). Is the current way the only way to give the text a relative size? Cheers, Raphael >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe << |
|
|
Re: Setting relative font sizesAm Samstag 24 Oktober 2009 22:19:13 schrieb Raphael Kubo da Costa:
> Currently, I have some QLabels with rich text in them, such as "<font > size=+1>foo</font>". I'm trying to move this kind of font setting to a > style sheet in the .ui, or even set it via QLabel::setStyleSheet, > however setting the style sheet to "font-size: larger;" or anything > that's not a pixel or point value doesn't work, and I don't know if > it's possible to set the size in a relative way (like the +1 that's > being used at the moment). font-size: 120%; font-size: 1.2em; Pack one of these in the stylesheet. Greetings Stefan >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe << |
|
|
Re: Setting relative font sizes"large" afaik should work
iirc, richtexts labels are silent QTextBrowsers, thus have support for the html subset. The direct way would of course be: QFont fnt = widget->font(); if (fnt.pointSize() > -1) fnt.setPointSize(fnt.pointSize()+n); else fnt.setPixelSize(fnt.pixelSizeSize()+m); widget->setFont(fnt); works for sure ;-) Thomas Am Saturday 24 October 2009 schrieb Raphael Kubo da Costa: > Hi there, > > Currently, I have some QLabels with rich text in them, such as "<font > size=+1>foo</font>". I'm trying to move this kind of font setting to a > style sheet in the .ui, or even set it via QLabel::setStyleSheet, > however setting the style sheet to "font-size: larger;" or anything > that's not a pixel or point value doesn't work, and I don't know if > it's possible to set the size in a relative way (like the +1 that's > being used at the moment). > > Is the current way the only way to give the text a relative size? > > Cheers, > Raphael > > >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to > >> unsubscribe << > >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe << |
|
|
Re: Setting relative font sizesOn Sat, Oct 24, 2009 at 6:32 PM, Stefan Majewsky <majewsky@...> wrote:
> Am Samstag 24 Oktober 2009 22:19:13 schrieb Raphael Kubo da Costa: >> Currently, I have some QLabels with rich text in them, such as "<font >> size=+1>foo</font>". I'm trying to move this kind of font setting to a >> style sheet in the .ui, or even set it via QLabel::setStyleSheet, >> however setting the style sheet to "font-size: larger;" or anything >> that's not a pixel or point value doesn't work, and I don't know if >> it's possible to set the size in a relative way (like the +1 that's >> being used at the moment). > > font-size: 120%; > font-size: 1.2em; > > Pack one of these in the stylesheet. > > Greetings > Stefan fileName->setStyleSheet("font-size: 120%;"); Doesn't change the font size at all (the 'em' version doesn't work either). What's weird is that Qt's documentation states explicitly in http://doc.trolltech.com/4.6-snapshot/stylesheet-reference.html#list-of-properties that only px and pt metrics are supported, but the example for the "font" property uses "large" for font-size. >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe << |
|
|
Re: Setting relative font sizesOn Sat, Oct 24, 2009 at 6:33 PM, Thomas Lübking <thomas.luebking@...> wrote:
> "large" afaik should work > iirc, richtexts labels are silent QTextBrowsers, thus have support for the > html subset. I've set the textFormat property in the .ui file to Qt::RichText, but setting font-size via setStyleSheet or the styleSheet property in the .ui doesn't work unless it's in pt or px. > The direct way would of course be: > > QFont fnt = widget->font(); > if (fnt.pointSize() > -1) > fnt.setPointSize(fnt.pointSize()+n); > else > fnt.setPixelSize(fnt.pixelSizeSize()+m); > widget->setFont(fnt); > > works for sure ;-) Is this the only possible way to do that then? > > Thomas > > Am Saturday 24 October 2009 schrieb Raphael Kubo da Costa: >> Hi there, >> >> Currently, I have some QLabels with rich text in them, such as "<font >> size=+1>foo</font>". I'm trying to move this kind of font setting to a >> style sheet in the .ui, or even set it via QLabel::setStyleSheet, >> however setting the style sheet to "font-size: larger;" or anything >> that's not a pixel or point value doesn't work, and I don't know if >> it's possible to set the size in a relative way (like the +1 that's >> being used at the moment). >> >> Is the current way the only way to give the text a relative size? >> >> Cheers, >> Raphael >> >> >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to >> >> unsubscribe << >> > > >>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe << > >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe << |
|
|
Re: Setting relative font sizesAm Saturday 24 October 2009 schrieb Raphael Kubo da Costa:
> Indeed, it worked :) > > Is this the only possible way to do that then? Apparently. I don't know if the css lack is a bug, but Qt is a cpp framework - i guess the css support is rather intended to pass UI design choices to the end user. Personally I'd always use the cpp API as setStyleSheet() (esp. on qApp) might easily lead to conflicts. (Though it's conveniant, i know) >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe << |
| Free embeddable forum powered by Nabble | Forum Help |