【发布时间】:2012-08-22 11:41:02
【问题描述】:
我正在编写一些类,它扩展了 QObject 并且几乎没有 Q_PROPERTY 我在 QList 中使用一个角色(总是返回 QObject* )在 QAbstaction 模型中使用它; 在 QML 中,我会使用 TextEdit 绑定属性,例如:
Binding
{
target :currentReport
property: description
value: text_description_edit.text
}
但是这个条目返回错误并且没有绑定我的属性:
file:///..somePath../ReportAddDelegate.qml:179: ReferenceError: Can't find variable: description
如何在 qml 中编辑我的 QObject 属性?
更新:
我在委托组件中使用property QtObject currentReport
//对不起我的英语
【问题讨论】:
-
显示属性
description定义。它应该有WRITE、READ和NOTIFY部分。 -
是的,它有 Q_PROPERTY(QString description WRITE setDescription READ getDescription NOTIFY descriptionChanged)
-
顺便说一句,如果我这样写:TextEdit {... text: curretnReport.description } 那么我没有错误,我在 TextEdit 中看到了文本,但如果我编辑它,我不会t 编辑对象中的描述属性