QML Summary 1-(a simple QML program)

Source: Internet
Author: User

QML also called Qt quick. Qt Quick is an advanced user interface technology. It makes it easy to create dynamic touch-side and lightweight applications for mobile and embedded devices. Three new technologies together form the QT Quick user interface: An improved QT Creator IDE, a new easy-to-learn language (QML), and a newly added module called the QT Library named Qtdeclarative, which makes QT more accessible for unfamiliar C + + For developers and designers who use it.

1.scene Scenario Tool:

Is the QT built-in view of a single QML file running results of the EXE program, can be found in the directory of the Qt bin, called Qmlscene.exe; Open will go directly to the file selection, when you choose to navigate to the corresponding QML file, you can see the effect of running.

2. A simple Hello Program

<1> new QT Selection qt Quick Application project

<2> if it is qt5.4 and above, will be prompted whether to establish the opposite interface file, you can choose, or do not choose.


<3> if the interface file is selected, the following MAIN.QML file will be generated by default

Import QtQuick 2.4
Import Qtquick.window 2.2
Window {
    Visible:true
    width:640
    height:480
    TITLE:QSTR ("Hello World")
    MainForm {
        Anchors.fill:parent
        Mousearea.onclicked: {
            Qt.quit ();
        }
    }
}

The run will find the word "Hello World" in the middle of the screen, but obviously this is not the hello we want. At this point, if you modify the Hello World in the title, you will find that the program you are running only changes the title and the content is unchanged. Careful observation, found below the application of a MainForm object, you can try to open it, you will find that there are two types of text editing mode and interface mode, both states can modify the interface.

However, if you want to generate a program to print hello in a single qml, which is our main.qml, then you need to delete the MainForm section and modify it to the following code:

text{
        Text: "Hello";
        Anchors.centerIn:parent
        Color: "Cyan"
        Font.pointsize:30
    }
The operation is now found to be correct, but our interface file is not called at this time .... (Individuals feel that they can choose between two ways according to their own habits)



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.