Creating C++ objects in QML [solved]
Not sure trying to do this from QGuiApplication makes sense. I'm getting "undeclared identifier " from the qmlRegisterType line in my main function:
Q_DECL_EXPORT int main(int argc, char *argv)
QGuiApplication app(argc, argv);
qmlRegisterType<Recording>("Games", 1, 0, "Recording"); QtQuick2ApplicationViewer viewer; viewer.setMainQmlFile(QStringLiteral("qml/Games/recordCurrentSong.qml")); viewer.showExpanded(); return app.exec();
Can someone point me in the right direction? I've done lots of reading and not enough tinkering to start understanding all this properly... Many thanks
ps - in case it's pertinent, here's the Games.pro file:
Add more folders to ship with the application, here
folder_01.source = qml/Games
folder_01.target = qml
DEPLOYMENTFOLDERS = folder_01
Additional import path used to resolve QML modules in Creator's code model
The .cpp file which was generated for your project. Feel free to hack it.
SOURCES += main.cpp
Please do not modify the following two lines. Required for deployment.
[edit: please add @ tags around your code for better readability , Eddy]
Can you show us the contents of recording.h
Maybe an Uppercase typo?
I just got it! Thanks Eddy - I needed to add #include <QtQml>
First time I see something calling c++ from QML. I'm excited. :-)
Good deal you solved it.
Please edit your first post and add [solved] in your title.
Done! Enjoy your Saturday!