Solved Q_PROPERTY from official doc creating error. Why?
-
Hello!
Just got confused about this code from official docs:QObject *object = ... const QMetaObject *metaobject = object->metaObject(); int count = metaobject->propertyCount(); for (int i=0; i<count; ++i) { QMetaProperty metaproperty = metaobject->property(i); const char *name = metaproperty.name(); QVariant value = object->property(name); ... }
There are error like this
The question why?
I am using qt 5.12.4 and Qt Creator 4.9.2 -
@bogong hi
try #include <QMetaProperty> -
@bogong said in Q_PROPERTY from official doc creating error. Why?:
The question why?
The error message tells you why: "
incomplete return type 'QMetaProperty'
" means you're missing the header for QMetaProperty.@LeLev gave the correct solution.
-
@LeLev @JKSH This is the first that I've been checking. But it's included and showing that couldn't find it. After last update of Qt Creator on Mac sometimes it's showing that could not find something from Qt. Only reconfiguring project helping.
-
@bogong Please show how you include it.
Also, you need this in your pro file:QT += core
-
@jsulm @JKSH @LeLev Thanks everyone. I don't know what was there but clearing cache and reconfiguring project solved the problem. We are working together with few developers they are working on Linux and Windows. They do not have the same problems after update. It's not the first time when clearing cache and deleting *.pro.user file solving this kind of troubles.
-
Hi,
.pro.user files are machine specific, you should not have them in your version control system.
-
@sgaist I know it perfectly. And there are nothing about what you've been writing. The problem is in updates only on MacOS, but I do not know what in precise.
Just got the same trouble on creating new project from scratch. For now Qt Creator do not see QtQuick.Window 2.12
There are everything from default of Qt Creator Wizard.
Sometimes it's do not see something random after updates. And only on MacOS.
But in menu it's appearing
The same situation might be for any includes. -
I don't know why but it's working when switched OFF QtCreator-> help -> About Plugins->ClangCodeModel
The same issue was before https://forum.qt.io/topic/100408/qt-creator-strange-behaviour-how-to-fix-it/11 and it's happening only on MacOS