开发者

Qt Stylesheets with derived classes

开发者 https://www.devze.com 2022-12-25 18:05 出处:网络
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 styleshee

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;
};
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号