Commit 7f6b91c1 authored by Jerome Pasion's avatar Jerome Pasion
Browse files

Doc: Added a section about the controls in the First Steps with QML page.


-added near the top to imply that the controls is a starting point.

Task-number: QTBUG-33595
Change-Id: I31290629dd9bca3c1e477140bc530b8b4b565dba
Reviewed-by: default avatarVenugopal Shivashankar <venugopal.shivashankar@digia.com>
Showing with 71 additions and 9 deletions
doc/src/images/applicationwindow.png

4.47 KB

...@@ -100,7 +100,7 @@ Rectangle { ...@@ -100,7 +100,7 @@ Rectangle {
If we save that document as "HelloWorld.qml", we can load and display it. If we save that document as "HelloWorld.qml", we can load and display it.
\section1 Loading and Displaying the QML Document \section1 Creating and Running QML Projects
To display the graphical scene defined by the QML document, it may be loaded To display the graphical scene defined by the QML document, it may be loaded
with \l{Qt Creator Manual}{Qt Creator}. For simple UI files such as this one, with \l{Qt Creator Manual}{Qt Creator}. For simple UI files such as this one,
...@@ -117,6 +117,74 @@ the following pages: ...@@ -117,6 +117,74 @@ the following pages:
\li \l{Qt Creator: Building and Running an Example}{Building and Running an Example} \li \l{Qt Creator: Building and Running an Example}{Building and Running an Example}
\endlist \endlist
\section1 Creating QML Applications with Controls
While Qt Quick provides basic graphical elements, \l{Qt Quick Controls} provides
ready-made QML types for use within an application.
Inserting the \l ApplicationWindow type is a good starting point for creating
applications. An application UI has this basic layout:
\image applicationwindow.png
Within each area, different \e controls may be added and connected to form
an application. For example, the following snippet is a basic application that
uses the previous layout:
\qml
//import related modules
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Window 2.2
//window containing the application
ApplicationWindow {
//title of the application
title: qsTr("Hello World")
width: 640
height: 480
//menu containing two menu items
menuBar: MenuBar {
Menu {
title: qsTr("File")
MenuItem {
text: qsTr("&Open")
onTriggered: console.log("Open action triggered");
}
MenuItem {
text: qsTr("Exit")
onTriggered: Qt.quit();
}
}
}
//Content Area
//a button in the middle of the content area
Button {
text: qsTr("Hello World")
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
}
}
\endqml
The application has two menu items and a button in the middle. Clicking on the
\uicontrol Exit menu item closes the application.
There are also different navigation methods and different controls such as
buttons and sliders available. The following examples are available from
Qt Creator and demonstrate different controls and layouts.
\list
\li \l{Qt Quick Controls - Basic Layouts Example}{Basic Layouts}
\li \l{Qt Quick Controls - Touch Gallery}{Touch Gallery}
\endlist
Feel free to copy and paste the snippets onto this simple Hellow World
application to see how QML works.
\section1 Handling User Input \section1 Handling User Input
One of the great advantages of using QML to define a user interface is that it One of the great advantages of using QML to define a user interface is that it
...@@ -127,8 +195,6 @@ as \l{Signal and Handler Event System}{signals} and these signals are handled by ...@@ -127,8 +195,6 @@ as \l{Signal and Handler Event System}{signals} and these signals are handled by
For example, consider the following example: For example, consider the following example:
\qml \qml
import QtQuick 2.3
Rectangle { Rectangle {
width: 200 width: 200
height: 100 height: 100
...@@ -154,8 +220,6 @@ signal for touch events, so this code will also work on a mobile device. ...@@ -154,8 +220,6 @@ signal for touch events, so this code will also work on a mobile device.
Keyboard user input can be similarly handled with a simple expression: Keyboard user input can be similarly handled with a simple expression:
\qml \qml
import QtQuick 2.3
Rectangle { Rectangle {
width: 200 width: 200
height: 100 height: 100
...@@ -191,8 +255,6 @@ were to change, the geometry of each child \l Rectangle would automatically ...@@ -191,8 +255,6 @@ were to change, the geometry of each child \l Rectangle would automatically
update due to the property bindings. update due to the property bindings.
\qml \qml
import QtQuick 2.3
Rectangle { Rectangle {
width: 400 width: 400
height: 200 height: 200
...@@ -218,8 +280,6 @@ to a property's value. In the following example, a property is animated which ...@@ -218,8 +280,6 @@ to a property's value. In the following example, a property is animated which
then gets displayed in a \l Text area: then gets displayed in a \l Text area:
\qml \qml
import QtQuick 2.3
Rectangle { Rectangle {
color: "lightgray" color: "lightgray"
width: 200 width: 200
...@@ -241,6 +301,7 @@ Rectangle { ...@@ -241,6 +301,7 @@ Rectangle {
The value being displayed will vary from 0 to 150 periodically. The value being displayed will vary from 0 to 150 periodically.
\section1 Defining Custom QML Types for Re-use \section1 Defining Custom QML Types for Re-use
One of the most important concepts in QML is that of type re-use. An One of the most important concepts in QML is that of type re-use. An
...@@ -276,6 +337,7 @@ The follow page will lead you in your journey with QML. ...@@ -276,6 +337,7 @@ The follow page will lead you in your journey with QML.
\list \list
\li \l{QML Applications} \li \l{QML Applications}
\li \l{Qt Examples and Tutorials}
\endlist \endlist
*/ */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment