3

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?

Mike
  • 693
  • 3
  • 13

1 Answers1

2

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;
};
bitc
  • 1,588
  • 13
  • 15