PDA

View Full Version : Can style sheets control rich text elements?



wrdieter
5th August 2009, 16:05
I would like to change all of the h1 elements in all of the QLabels in my program to be blue. Is there an easy way to do this with a style sheet?

I tried:


QLabel.H1 { color: blue }


and


QLabel::H1 { color: blue }

and a few other things that I thought might work, but no luck so far.

I am not clear from the documentation if this is something that is supported or it is just matter of bad syntax. Has anyone done this before? Is it possible to use style sheets to control the formatting of rich text elements in a QLabel? Is there a different way to get consistent formatting of particular elements within the GUI that I should be using?

wagmare
6th August 2009, 08:18
simple way is to use tags

QLabel *label;
label->setText("<i><font color=blue>Ok</font></i>");

i think we cant control font color through styleSheet ..

wrdieter
6th August 2009, 13:47
simple way is to use tags

QLabel *label;
label->setText("<i><font color=blue>Ok</font></i>");

i think we cant control font color through styleSheet ..

I can change an individual item easily that way. What I want to do is change all h1 elements in all QLabels throughout my program. HTML can do this with CSS stylesheets. Since the Qt stylesheets are based on CSS, I thought this might be possible with Qt as well.

From the documentation, I cannot tell if what I want is unsupported or if I am just doing it the wrong way. If anyone knows how to change the style for an h1 (or other HTML) element, please let me know.

Thanks,
Bill.