SetMainQmlFile it doesn't work
-
Hi guys....
I have this qrc file:
@
<RCC>
<qresource prefix="/">
<file>qml/pilarApp/main.qml</file>
</qresource>
</RCC>
@and in my main.cpp I have:
@
QGuiApplication app(argc, argv);
QtQuick2ApplicationViewer viewer;
viewer.rootContext()->setContextProperty("PilarApp", new System);
viewer.setMainQmlFile(QStringLiteral("qrc:/qml/pilarApp/main.qml"));
viewer.showExpanded();
return app.exec();@but it doesn't work
I had try with:
@
"qrc:/qml/pilarApp/main.qml"
"qrc://qml/pilarApp/main.qml"
":/qml/pilarApp/main.qml"
"://qml/pilarApp/main.qml"
@and the error which wtcreator give me is like this:
@
file:///home/freddy/Trabajo/eulerideas/Salon Pilar App/qt-creator/build-pilarApp-Clang-Debug/qrc:/qml/pilarApp/main.qml: File not found
@in my .pro file I have defined
@
RESOURCES +=
resource.qrc
@so.... what i'm doing wrong ???
best regards to everyone
freddy
-
Hi,
Try
@
viewer.setSource(QUrl("qrc:/qml/pilarApp/main.qml"));
@
instead of
@
viewer.setMainQmlFile(QStringLiteral("qrc:/qml/pilarApp/main.qml"));
@ -
Hi p3c0.... Thanks for answer....
your solution solve my problem, but.... what happend if the I use QtQuick2ControlsApplicationViewer class instead QtQuick2ApplicationViewer class ???
this class don't have setSource method because this class, which is generated by the QtCreator project, doesn't inherit from QQuickView
regards
-
Hi freddy311082,
See my 2nd post at http://qt-project.org/forums/viewthread/37597 . Qt Creator forgot to generate the relevant code, but you can add it yourself. (This issue is fixed for Qt Creator 3.1, which will be released with Qt 5.3)
-
Hi JKSH
I had read your post, but I don't have clear something...
if i have this code into my main function:
@
Application app(argc, argv);
QtQuick2ControlsApplicationViewer viewer;
QQmlEngine *engine = viewer.engine();
QQmlContext *context = engine->rootContext();
context->setContextProperty("systemControler", new System);
viewer.setMainQmlFile(QStringLiteral("/qml/adviser/main.qml"));
viewer.show();
return app.exec();
@how can I change the line where I'm calling setMainQmlFile ?? your post make porpose add a new definition to the QtQuick2ControlsApplicationViewer class, but let be clear how fix this problem...
regards my friend
-
Hi freddy311082,
I don't see anything wrong with your code and you shouldn't need to change that line. What issue are you facing?
-
Hi JKSH
I need change the following line
@
viewer.setMainQmlFile(QStringLiteral("/qml/adviser/main.qml"));
@by someone like this
@
viewer.setMainQmlFile(QStringLiteral("qrc:/qml/adviser/main.qml"));
@but the last one it odesn't work
who can I do that using QtQuick2ControlsApplicationViewer class ?? that is my question
regards
-
Hi freddy311082,
It looks like other people are struggling with this issue too: https://bugreports.qt-project.org/browse/QTCREATORBUG-11277 It will be fixed for Qt Creator 3.1.
In the meantime, you can edit the generated code. Open qtquick2controlsapplicationviewer.cpp and change this line:
@
void QtQuick2ControlsApplicationViewer::setMainQmlFile(const QString &file)
{
...
// component.loadUrl(QUrl::fromLocalFile(d->mainQmlFile));
component.loadUrl(QUrl(file));
...
}
@