QML > Qt > Android
-
Hello,
I hope, I am right here, I have a little question:
In Qt Quick 2.0 I create a gui thats uses two states. Then I compile this in Qt 5. There both states unexpectedly are displayed side by side. And if I want to compile this for Android, I just see an empty window.
Also if I only create a blue rectangle in QML: In Qt all it's ok, but on Android there is only an empty space.
What can I do?Thank you for answers.
-
I have watched as their problems.
Want to use QML in android, but I want to use QWidget, and I'm always wrong. But until now pure QML worked well with me since well configured. -
Examples of Qt, worked well with me.
And they worked as follows. The QML and images are within a file.qrc and then run the main.
I'm waiting out 5.2, but until we live malfunctions.
Hope this helps.
-
At first, thank you for your post. Unfortunately, I don't really understand.. the QML becomes automatically included in qrc-file or have I to do anything for this?
What I did until now: I create this main.cpp to import there QML. So I can compile it.@
#include <QApplication>
#include <QtQml/QQmlEngine>
#include <QtQuick/QQuickView>int main(int argc, char *argv[]) {
QApplication app(argc, argv);
QQuickView view;
view.setSource(QUrl::fromLocalFile("QtState.qml")); //QML-file
view.show();
return app.exec();
}
@So the project-file is configured:
@
QT += qml quick
greaterThan(QT_MAJOR_VERSION, 4): QT += widgetsTARGET = QtAnd
TEMPLATE += appSOURCES += main.cpp
HEADERS +=CONFIG += mobility
MOBILITY =OTHER_FILES += QtState.qml
@Could it be, there is anything wrong?
-
i think you have to add the QtState.qml file to qrc and load it like this:
@
view.setSource(QUrl("qrc:///QtState.qml"));
@
instead of loading it from the filesystem. Just add it to the OTHER_FILES variable in your PRO file isn't enough. -
Unfortunately it didn't help, although I think I am further because of you now. Perhaps in Qt 5.2 it becomes more easier or I find another way.. :(
-
show your code (PRO, qrc, cpp) files again please.
-
Yup. There is my PRO-file:
@
QT += qml quickgreaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = QtAnd
TEMPLATE += appSOURCES += main.cpp
HEADERS +=
CONFIG += mobility
MOBILITY =OTHER_FILES +=
QtState.qml
android/AndroidManifest.xml
android/res/layout/splash.xml
android/res/values/libs.xml
android/res/values/strings.xml
android/res/values-de/strings.xml
android/res/values-el/strings.xml
android/res/values-es/strings.xml
android/res/values-et/strings.xml
android/res/values-fa/strings.xml
android/res/values-fr/strings.xml
android/res/values-id/strings.xml
android/res/values-it/strings.xml
android/res/values-ja/strings.xml
android/res/values-ms/strings.xml
android/res/values-nb/strings.xml
android/res/values-nl/strings.xml
android/res/values-pl/strings.xml
android/res/values-pt-rBR/strings.xml
android/res/values-ro/strings.xml
android/res/values-rs/strings.xml
android/res/values-ru/strings.xml
android/res/values-zh-rCN/strings.xml
android/res/values-zh-rTW/strings.xml
android/src/org/kde/necessitas/ministro/IMinistro.aidl
android/src/org/kde/necessitas/ministro/IMinistroCallback.aidl
android/src/org/qtproject/qt5/android/bindings/QtActivity.java
android/src/org/qtproject/qt5/android/bindings/QtApplication.java
android/version.xmlRESOURCES +=
res.qrc
@My main.cpp:
@
#include <QApplication>
#include <QtQml/QQmlEngine>
#include <QtQuick/QQuickView>int main(int argc, char *argv[]){
QApplication app(argc, argv);
QQuickView view;
//Also I try this path: qrc:/QtState.qml
view.setSource(QUrl("qrc:///QtState.qml"));
view.show();return app.exec();
}
@My qrc-file:
@
<RCC>
<qresource prefix="/">
<file>QtState.qml</file>
</qresource>
</RCC>
@ -
i can't find an error at the first glance.
You can make sure that the QtState.qml file gets found by Qt:
@
qDebug() << "QML file exists?" << QFile(":/QtState.qml").exists();
@If true is returned you can go and "debug the QML file":http://qt-project.org/doc/qt-5.0/qtquick/qtquick-debugging.html itself. This is also possible out of QtCreator on remote devices.
This may also be interesting for you: set the following environment variable to debug the imports of QML types: QML_IMPORT_TRACE=1
-
Thank you.
I will try it in the next days. :)