You can define the UI by adding a QML file that declares the UI components of your new app.
To define the UI:
-
Click the Edit icon on the left side, right-click the QtApp folder in the
Projects view, then choose Add New... in the popup menu.
-
In the New File dialog, select Qt in the Files and Classes
list, then QML File (Qt Quick 2) in the list of file types (shown in the middle), then click
Choose...
-
In the Location page of the New QML File dialog, name the file
main, then click Next.
-
In the Summary page, click Finish.
The main.qml file is opened for editing.
-
Delete the default file content and replace it with the following:
import QtQuick 2.0
Rectangle {
width: 360
height: 360
Text {
text: qsTr("Hello World")
anchors.centerIn: parent
}
}
This QML code defines a simple UI consisting of a box displaying
Hello World.
Note:
The QNX Apps and Media reference image has a similar HTML5 sample that displays "Hello World"
but here, we're writing an app with a basic UI to demonstrate Qt app development and deployment.
In fact, you can replace the QML code here with whatever you like to display a different UI.
-
Save the file.