gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 04:43:41 24 4
gpt4 key购买 nike

我有一个像这样的自定义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 .

关于c++ - 我可以从样式表 (qss) 更改自定义动态属性吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58126182/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com