Qt Stylesheets with derived classes
Can I use Qt stylesheets with a derived开发者_运维技巧 widget? I'd like to be able to define some custom properties on the widget (like various colors) and be able to define their value in a stylesheet.
Is this possible?
Sure, just declare your properties with Q_PROPERTY.
class MyClass : public QObject
{
Q_OBJECT
Q_PROPERTY( int fun READ getFun WRITE setFun )
public:
MyClass( QObject * parent=0, const char * name=0 );
~MyClass();
void setFun( int x );
int getFun() const;
};
精彩评论