QML learning: Rectangle, Text, TextEdit, Flickable, Flipable Elements

Source: Internet
Author: User


import QtQuick 2.0Item{    Rectangle    {        color: "blue"        width: 50        height: 50        border.color: "green"        border.width: 10        radius: 20    }}

Running effect:

Import QtQuick 2.0 Item {Rectangle {color: "blue" width: 50 height: 50 border. color: "green" border. width: 10 radius: 20} Text {// text Text: "Hello JDH! "// Font. family:" Helvetica "// font. pointSize: 24 // color:" red "}}

Running effect:

Import QtQuick 2.0 Item {Rectangle {color: "blue" width: 50 height: 50 border. color: "green" border. width: 10 radius: 20} Text {// text Text: "Hello JDH! "// Font. family: "Helvetica" // font. pointSize: 24 // color: "red"} TextEdit {width: 240 text: "This is TextEdit" font. pointSize: 10 focus: true x: 20 y: 40 }}

Running effect:

Import QtQuick 2.0 Flickable {id: flick width: 300 height: 200 // The content size contentWidth: image. width contentHeight: image. height Image {id: image source: "pics/1.jpg "}}

Code 2:

Import QtQuick 2.0 Rectangle {width: 480 height: 320 color: "blue" Flickable {id: flick width: 300 height: 200 // the size of the content that can be dragged contentWidth: image. width contentHeight: image. height // hide the clip: true; Image {id: image source: "pics/1.jpg"} That is greater than the display window "}}}
Running effect:

Code 3:

Running effect: 

Import QtQuick 2.0 Flipable {id: flip width: 300 height: 200 // define property bool flipped: false // front Image front: Image {source: "pics/1.jpg" anchors. centerIn: parent} // back Image back: Image {source: "pics/2.jpg" anchors. centerIn: parent} // Rotation settings, extended Y axis rotation transform: Rotation {id: rotation origin. x: flip. width/2 origin. y: flip. height/2 axis. x: 0 axis. y: 1 axis. z: 0 angle: 0} // status change states: State {name: "B Ack "PropertyChanges {target: rotation; angle: 180} when: flip. flipped} // conversion method transitions: Transition {NumberAnimation {target: rotation properties: "angle" duration: 4000 }}// MouseArea {anchors in the mouse area. fill: parent onClicked: flip. flipped =! Flip. flipped }}
:

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.