我真的想不通为什么我需要它,一直在阅读: http://doc.qt.io/qt-4.8/properties.html#requirements-for-declaring-properties
还是不能真正理解它的用途。 任何形式的帮助都会很棒!
最佳答案
了解 Qt Property System ,这就像一个普通的类方法,但它可以与 Qt 的元对象系统一起使用:
QPushButton *button = new QPushButton;
QObject *object = button;
button->setDown(true);
object->setProperty("down", true);
此外,这些属性在 Qt Designer 下也是可见的,因此您可以创建具有某些属性的自定义小部件并将其连接到 Qt Designer 中,请参阅 this article了解详情。
关于c++ - Qt 中的 Q_PROPERTY?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4722279/