Hi,
I’m on the way to port my applications (desktop) to mobile phones (android).
I read a lot of times, that it’s strongly recommended to use QML instead of desktop Qt for mobile devices, because it would avoid lots of errors, is that right?
Well, I tried starting a new Qt Quick project by using the Qt Quick tutorial. The example code in the tutorial looks like that:
import QtQuick 2.3
Rectangle {
id: simpleButton
color: "grey"
width: 150; height: 75
Text {
id: buttonLabel
anchors.centerIn: parent
text: "button label"
}
}
import QtQuick 2.3
Rectangle {
id: simpleButton
color: "grey"
width: 150; height: 75
Text {
id: buttonLabel
anchors.centerIn: parent
text: "button label"
}
}
To copy to clipboard, switch view to plain text mode
The problem is, they “compile†or “run†the code above using qmlscene without using any other stuff (c++ source files, headers, resource files, pri files and so on…).
In my case, I’d really like to use QtCreator and so, I have to create a project.
When I do that, it creates a lot of files:
1. the .pro file
2. deployment.pri
3. main.cpp
4. main.qml
5. MainForm.ui.qml
When I run that project, everything works fine, but I don’t think I need all those files when Qt Quick tutorial only uses one qml file.
When I remove all those files except the main.cpp (where the main.qml is loaded) and the main.qml and try to run the project, no errors occure, the executable is created and it runs, but nothing happens. There is no UI created…
Does anyone know why? What am I doing wrong?
That is my project:
.pro file:
TEMPLATE = app
QT += qml quick widgets
SOURCES += main.cpp
DISTFILES += main.qml
TEMPLATE = app
QT += qml quick widgets
SOURCES += main.cpp
DISTFILES += main.qml
To copy to clipboard, switch view to plain text mode
main.cpp
#include <QApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QQmlApplicationEngine engine;
engine.load("main.qml");
return app.exec();
}
#include <QApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load("main.qml");
return app.exec();
}
To copy to clipboard, switch view to plain text mode
main.qml:
import QtQuick 2.3
Rectangle {
id: simpleButton
color: "grey"
width: 150; height: 75
Text {
id: buttonLabel
anchors.centerIn: parent
text: "button label"
}
}
import QtQuick 2.3
Rectangle {
id: simpleButton
color: "grey"
width: 150; height: 75
Text {
id: buttonLabel
anchors.centerIn: parent
text: "button label"
}
}
To copy to clipboard, switch view to plain text mode
Can anyone help me with that? 
Thank you in anticipation!
Bookmarks