PDA

View Full Version : Starting Qt quick using a book



franky
28th August 2017, 17:27
Hi,
Using this example (https://qmlbook.github.io/en/ch04/index.html#qml-syntax), firstly, I created an "Application > Qt Quick application project".
I didn't change the main.cpp and 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 I created exactly the one the book has used?
2-Do I need to keep the Window section? If so why isn't it shown in the example?
3- Shouldn't I change anything in main.cpp?
4- I built the project using the Arm Android kit but the size of the APK files for both Release and Debug modes are the same. I expected to have a smaller size for the Release mode. :(

Thank you.

wysota
29th August 2017, 06:25
1- Is the type of the project I created exactly the one the book has used?
No but if you want to get an APK then the project type you have chosen is the correct one.


2-Do I need to keep the Window section? If so why isn't it shown in the example?
No, you don't have to in general. But for the project implementation you have chosen it makes sense to start with a Window.


3- Shouldn't I change anything in main.cpp?
No.


4- I built the project using the Arm Android kit but the size of the APK files for both Release and Debug modes are the same. I expected to have a smaller size for the Release mode. :(

Your project has just a single cpp file (main.cpp) which is trivial so there is nothing to bloat your executable. For pure QML projects it doesn't have any practical effect to do a debug build.

franky
29th August 2017, 08:05
No but if you want to get an APK then the project type you have chosen is the correct one.

My question here is, how to create the project used in the example? I mean, what template/class to choose?

And if I create a new project that way, won't I have APK files for the project?!

wysota
29th August 2017, 08:48
My question here is, how to create the project used in the example? I mean, what template/class to choose?
Other Projects -> QtQuick UI Prototype (or something similar).


And if I create a new project that way, won't I have APK files for the project?!
No, since you would be running the project on the desktop only. This type of project is not suitable for deployment on Android.