PDA

View Full Version : Custom painting and stylesheets



arturo182
8th March 2009, 00:40
I'm not sure if it's possible, but I would like to achive something like this:
I have a class that inherits QWidget, it uses paintEvent to draw some text and rectangles, what I would like to achive is get color of text and those rectangles from style sheet.

Pseudocode:

C++


QColor color = this->getStyleSheet().getClass('MyWidget').getProperty(' color');


CSS


.MyWidget {
color: #cdcdcd;
}


Is it possible to do in QT or do I have to store colors and other style information some other way?

JimDaniel
8th March 2009, 04:13
Is it necessary that you get the information from a css format? If so I believe you would have to roll your own parser. However you could easily do the same thing using XML which Qt does have support for.

arturo182
8th March 2009, 11:14
It's a little strange that QT allows setting style sheets but not getting any style properties, I mean it surely has some CSS parser, I guess it's not public.

Ok then, I'm gonna go with XML, thanks ;)