Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.12.2
-
None
Description
After few hours of playing around with Q_PROPERTY, to properly export a value to qml, there are few things I found:
- there is almost nothing about that Q_PROPERTY expects pointer to type instead of type:
this results in empty value in qml
Q_PROPERTY(Result result READ GetResult CONSTANT FINAL)
On the other hand almost all examples in documentation uses type instead of pointer to type
Works because automatic conversion of Qt types to JavaScript typesQ_PROPERTY(QString author READ author WRITE setAuthor NOTIFY authorChanged) Q_PROPERTY(QDateTime creationDate READ creationDate WRITE setCreationDate NOTIFY creationDateChanged)
what is quite misleading without explicit the explanation that the other QObject types require pointer.
Only this is working properly for QObject typesQ_PROPERTY(Result* result READ GetResult CONSTANT FINAL)
After some time I found it's mentioned in documentation once, but there is no warning that anything else would not work.
On the other hand there is nothing about such requirement at Q_PROPERTY documentation page. - There is nothing in documentation about that there is no way to keep const correctness at all when trying to export type to qml
Q_PROPERTY(const Result* result READ GetResult CONSTANT FINAL)