2

I have a custom QFramelike this

//! Widget which displays a audio level meter, indicating the
//! level and peak levels of the window of audio samples most recently analyzed
class BLACKGUI_EXPORT CLevelMeter : public QFrame
{
    Q_OBJECT
    Q_PROPERTY(QColor lowColor  READ getLowColor  WRITE setLowColor)
    Q_PROPERTY(QColor highColor READ getHighColor WRITE setHighColor)
    Q_PROPERTY(QColor peakColor READ getPeakColor WRITE setPeakColor)

I want to set those colors in an qss stylesheet like this

BlackGui--CLevelMeter {
  lowColor: blue;
  border: 1px solid grey;
  border-radius: 5px;

This does NOT work, any chance to do this?

Horst Walter
  • 13,663
  • 32
  • 126
  • 228

1 Answers1

2

As the docs points out:

Setting QObject Properties

From 4.3 and above, any designable Q_PROPERTY can be set using the qproperty-<property name> syntax.

For example,

MyLabel { qproperty-pixmap: url(pixmap.png); }
MyGroupBox { qproperty-titleColor: rgb(100, 200, 100); }
QPushButton { qproperty-iconSize: 20px 20px; }

If the property references an enum declared with Q_ENUMS, you should reference its constants by name, i.e., not their numeric value.

You must use qproperty-lowColor.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241