简体   繁体   English

在Qt Designer自定义小部件中将QList作为属性

[英]QList as a property in qt designer custom widget

i have defined a custom widget, basically adding to QLabel. 我定义了一个自定义小部件,基本上添加到了QLabel中。 The simple (Qstring and enum ) properties are ok and appear in my QT designer. 简单的(Qstring和enum)属性可以,并显示在我的QT设计器中。

I am now trying to add a property which is a list. 我现在正在尝试添加一个属性,它是一个列表。

So I declare my property as : 所以我声明我的财产为:

 Q_PROPERTY(QList<int> points READ getpoints )

and I have my private variable QList<int> m_points; 我有我的私有变量QList<int> m_points;

Still, I cannot see my points property in QT designer propriety editor. 不过,我在QT设计器专有编辑器中看不到我的points属性。 And, I don't know what went wrong. 而且,我不知道出了什么问题。

I've tried to add the DESIGNABLE flag but it does nothing. 我试图添加DESIGNABLE标志,但是它什么也没做。

Any clue ? 有什么线索吗?

The problem stems from the fact I forgot the WRITE part in the property. 问题出在我忘记了属性中的WRITE部分。

Adding the set method and the Write in the Q_PROPERTY did the trick. 在Q_PROPERTY中添加set方法和Write即可达到目的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM