Unsolved A simple Qt Quick app
-
Hi,
Using this example I first created an "Application > Qt Quick application project".
I didn't change themain.cpp
(and it was strange and interesting that even QML is also based on C++! Well done C++!)
Then kept the Window part and entered the Rectangle section below that as follows:import QtQuick 2.6 import QtQuick.Window 2.2 Window { visible: true width: 640 height: 480 title: qsTr("Rec") Rectangle { id: root x: 50; y: 10 width: 120; height: 240 color: "Blue" Image { id: triangle x: root.width + width/2; y: height/2 source: "/triangle_red.png" } Text { y: 50 width: root.width color: "white" horizontalAlignment: Text.AlignHCenter text: "Triangle" } } }
The output is shown for Desktop. For other kits I just pressed the build button because I just needed the APK files.
My questions:
1- Is the type of the project exactly the one the book has used?
2-Do I need to keep theWindow
section? If so why it's not shown in the example?
3- Shouldn't I change anything inmain.cpp
?
4- I built the project using theArm Android
kit but the size of theAPK
files for bothRelease
andDebug
modes are the same. I expected to have a smaller size for theRelease
mode. :(thank you.
-
@tomy If using engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
Window is must.
If using QtQuickView to load the qml then can use Item/Components directly. -
@tomy QML is not based on C++. It is a JavaScript dialect, but it can interact with C++.
2. You can go without Window. Here is explained what this Window is: http://doc.qt.io/qt-5/qml-qtquick-window-window.html
3. How does main look and does the app work?
4. Release build should be smaller, indeed. You can inspect the content of both APKs to see what is in. -
- You can go without Window. Here is explained what this Window is: http://doc.qt.io/qt-5/qml-qtquick-window-window.html
Thank you. How long! I will read it later.
- How does main look and does the app work?
Here it's:
#include <QGuiApplication> #include <QQmlApplicationEngine> int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); if (engine.rootObjects().isEmpty()) return -1; return app.exec(); }
- Release build should be smaller, indeed. You can inspect the content of both APKs to see what is in.
How to inspect the contents of both APK files, please?
-
@tomy "How long!" - well, if you really want to learn something you need to invest time, nothing is for free :-)
Your main should be fine as long as you QML file is named main.qml and is in a resource file.
APK files are just ZIP archives. -
If using QtQuickView to load the qml then can use Item/Components directly.
So how to use it please?
-
Your main should be fine as long as you QML file is named main.qml and is in a resource file.
Yes, they are as I posted the code above.
APK files are just ZIP archives.
Do you mean I open those files using a zip player like winRaR, please!?
-
@tomy said in A simple Qt Quick app:
Do you mean I open those files using a zip player like winRaR, please!?
yes
-
I opened both APK files using winRaR. They are identical regarding their items and sizes!
And about the example without a Window, I still don't know how to apply for that. you lead me to read Docs while a two-line of explanation would solve my issue, I think.
So far, I've referred to the Docs and can't remember even one time they have been useful for me. I'm 100% sure (judging by my own experience on them) that, Docs are not useful "for beginners", and you repeatedly refer us to there.
I don't like to read Docs and learn Qt/QML or anything using them. They just confuse me. I may some day refer to the Docs, when I'm no longer a novice on Qt.
for the time being I rely only on books instead. This is my desire.