Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

Creating C++ objects in QML [solved]

$
0
0
Hi! Not sure trying to do this from QGuiApplication makes sense. I’m getting “undeclared identifier “ from the qmlRegisterType line in my main function: #include <QtGui/QGuiApplication> #include "qtquick2applicationviewer.h" #include <QQmlEngine>   #include "recording.h"   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 Mike 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 QML_IMPORT_PATH =   # The .cpp file which was generated for your project. Feel free to hack it. SOURCES += main.cpp \     recording.cpp   # Installation path # target.path =   # Please do not modify the following two lines. Required for deployment. include(qtquick2applicationviewer/qtquick2applicationviewer.pri) qtcAddDeployment()   OTHER_FILES += \     qml/Games/doRecordingView.qml   HEADERS += \     recording.h [edit: please add @ tags around your code for better readability , Eddy]

Viewing all articles
Browse latest Browse all 4972

Trending Articles