How to use Enum as QProperty + StyleSheet?
-
How to use an Enum as QProperty and update it value using a stylesheet?
class Gallery : public QScrollArea { Q_OBJECT Q_PROPERTY(int horizontalSpacing MEMBER horizontalSpacing) Q_PROPERTY(Orientation orientation MEMBER Orientation WRITE setOrientation) public: int horizontalSpacing; enum Orientation { TOP, BOTTOM, LEFT, RIGHT }; Orientation orientation; void setOrientation(Orientation orientation); };This is not compiling, the error:
C7624: Type name 'Gallery::Orientation' cannot appear on the right side of a class member access expressionMy goal is to dynamically update the value using a stylesheet as:
Gallery { qproperty-horizontalSpacing: 30; qproperty-orientation: top; } -
How to use an Enum as QProperty and update it value using a stylesheet?
class Gallery : public QScrollArea { Q_OBJECT Q_PROPERTY(int horizontalSpacing MEMBER horizontalSpacing) Q_PROPERTY(Orientation orientation MEMBER Orientation WRITE setOrientation) public: int horizontalSpacing; enum Orientation { TOP, BOTTOM, LEFT, RIGHT }; Orientation orientation; void setOrientation(Orientation orientation); };This is not compiling, the error:
C7624: Type name 'Gallery::Orientation' cannot appear on the right side of a class member access expressionMy goal is to dynamically update the value using a stylesheet as:
Gallery { qproperty-horizontalSpacing: 30; qproperty-orientation: top; }@Rua3n said in How to use Enum as QProperty + StyleSheet?:
Q_PROPERTY(Orientation orientation MEMBER Orientation WRITE setOrientation)
The member is wrong.
-
@Rua3n said in How to use Enum as QProperty + StyleSheet?:
Q_PROPERTY(Orientation orientation MEMBER Orientation WRITE setOrientation)
The member is wrong.
@Christian-Ehrlicher Now it compiled, but it's calling the
setOrientationfunction with a "wrong" valueUsing:
Gallery { qproperty-horizontalSpacing: 30; qproperty-orientation: "left"; }the
setOrientationfunction is not called.
Using:Gallery { qproperty-horizontalSpacing: 30; qproperty-orientation: left; }The function is called but, the value of
orientationis19, what does this mean?void Gallery::setOrientation(Orientation orientation) { } -
@Christian-Ehrlicher Now it compiled, but it's calling the
setOrientationfunction with a "wrong" valueUsing:
Gallery { qproperty-horizontalSpacing: 30; qproperty-orientation: "left"; }the
setOrientationfunction is not called.
Using:Gallery { qproperty-horizontalSpacing: 30; qproperty-orientation: left; }The function is called but, the value of
orientationis19, what does this mean?void Gallery::setOrientation(Orientation orientation) { }