3

I wrote Qt4 (or Qt5) class MyButton and defined two boolean properties, like this:

#include <QPushButton>

class MyButton : QPushButton
{
  Q_OBJECT
  Q_PROPERTY(bool property_1 READ property_1)
  Q_PROPERTY(bool property_2 READ property_2)
public:
  explicit MyButton(QWidget *parent = 0);
  ...
}

Now I want to customize application stylesheet in external file so that in different combinations of this properties MyButton has different background color. Separately this works well:

MyButton[property_1="true"] { background-color: black }
MyButton[property_2="true"] { background-color: white }

So the question is: how to combine few properties in the same condition with "and", "or" and "not" operations?

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
HapKoM
  • 319
  • 2
  • 10

1 Answers1

12

Finally I got the solution. The idea is the same as CSS attribute selection.

Thus property_1="true" AND property_2="true" condition is:

MyButton[property_1="true"][property_2="true"] { background-color: green; } 
Community
  • 1
  • 1
HapKoM
  • 319
  • 2
  • 10