我可以从样式表 (qss) 更改自定义动态属性吗?

Can I change custom dynamic properties from a stylesheet (qss)?

我有一个习惯QFrame像这样

//! 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)

我想在这样的 qss 样式表中设置这些颜色

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

这行不通,有机会这样做吗?

正如the docs指出的那样:

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.

您必须使用 qproperty-lowColor