Q_PROPERTY in Qt?

不羁的心 提交于 2019-12-08 16:22:37

问题


I cant really figure out why do I need it, Been reading: http://doc.qt.io/qt-4.8/properties.html#requirements-for-declaring-properties

still cant really understand the use of it. any kind of help would be great!


回答1:


Read about the Qt Property System , this is just like a usual class method but it can be used with Qt's meta-object system:

 QPushButton *button = new QPushButton;
 QObject *object = button;

 button->setDown(true);
 object->setProperty("down", true);

Also these properties will be visible under Qt Designer too so you could create a custom widget with some properties and hook it up in Qt Designer, see this article for details.




回答2:


Properties help in RTTI like implementation using Qt's Meta object system.



来源:https://stackoverflow.com/questions/4722279/q-property-in-qt

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!