Quantcast
Viewing all articles
Browse latest Browse all 4972

Qml file not getting found after adding to a resource file

Hi, I have got the following project : http://www.datafilehost.com/d/3e0d49d0 The main.cpp file in it reads as follows : #include <QGuiApplication> #include <QQuickView> int main(int argc, char* argv[]) {     QGuiApplication app(argc,argv);     QQuickView view;     view.setSource(QUrl(":/main.qml"));     view.setResizeMode(QQuickView::SizeRootObjectToView);     view.show();     return app.exec(); } The qml is in main.qml which I have added to the resource: <RCC>     <qresource prefix="/">         <file>main.qml</file>     </qresource> </RCC> But I still get an error : Starting F:\Code\Qt\build-RapidConcepts-Desktop_Qt_5_2_1_MSVC2012_32bit-Debug\debug\RapidConcepts.exe… QML debugging is enabled. Only use this in a safe environment. file:///F:/Code/Qt/build-RapidConcepts-Desktop_Qt_5_2_1_MSVC2012_32bit-Debug/:/main.qml: File not found 1. There is no prefix for the resource. I have accessed it using the propoer qrc syntax. Yet I do not get why its unable to find it. 2. I want to make this application a mixed QML and C++ application. So when I created the project I got this class by default which was used in main.cpp : #ifndef QTQUICK2APPLICATIONVIEWER_H #define QTQUICK2APPLICATIONVIEWER_H   #include <QtQuick/QQuickView>   class QtQuick2ApplicationViewer : public QQuickView {     Q_OBJECT   public:     explicit QtQuick2ApplicationViewer(QWindow *parent = 0);     virtual ~QtQuick2ApplicationViewer();       void setMainQmlFile(const QString &file);     void addImportPath(const QString &path);       void showExpanded();   private:     class QtQuick2ApplicationViewerPrivate *d; }; Why do I have to use this class at all. Cant I just use QQuickView directly as in the code I have given at the top of this post ? Why does Qt generate this extra class at all ?

Viewing all articles
Browse latest Browse all 4972

Trending Articles