Äú¿ÉÒÔ¾èÖú£¬Ö§³ÖÎÒÃǵĹ«ÒæÊÂÒµ¡£

1Ôª 10Ôª 50Ôª





ÈÏÖ¤Â룺  ÑéÖ¤Âë,¿´²»Çå³þ?Çëµã»÷Ë¢ÐÂÑéÖ¤Âë ±ØÌî



  ÇóÖª ÎÄÕ ÎÄ¿â Lib ÊÓÆµ iPerson ¿Î³Ì ÈÏÖ¤ ×Éѯ ¹¤¾ß ½²×ù Model Center   Code  
»áÔ±   
   
 
     
   
 ¶©ÔÄ
  ¾èÖú
QML£ºµÚÒ»¸öQMLÏîÄ¿·ÖÎö
 
  2669  次浏览      29
 2019-7-16
 
±à¼­ÍƼö:
±¾ÎÄÀ´×ÔÓÚcsdn£¬±¾ÎÄÖ÷Òª¼òµ¥½éÉÜÁËQMLµÄÅäÖÃÒÔ¼°¶ÔÏóµÄÊôÐÔºÍanchorsê²¼¾Ö£¬Ï£Íû¶ÔÄúµÄѧϰÄÜÓÐËù°ïÖú¡£

QMLÊÇÒ»ÖÖÉùÃ÷ʽÓïÑÔ£¬ËüÌṩÁËÒ»×é½Ó¿ÚÓÃÀ´ÃèÊö¿ÉÊÓ»¯×é¼þÒÔ¼°ËûÃÇÖ®¼äµÄ»¥¶¯¡£ËüÊÇÒ»¸ö¸ß¶È¿É¶ÁµÄÓïÑÔ£¬²¢ÇÒ±»Éè¼Æ³Éʹ×é¼þÒÔÒ»¸ö¶¯Ì¬µÄ·½Ê½Ï໥Á¬½Ó¡£Í¬Ê±Ëüʹ×é¼þºÜÈÝÒ×±»¸´ÓÃÒÔ¼°´´½¨¶¨ÖƵÄÓû§½çÃæ¡£Ê¹ÓÃQtQuickÄ£¿é£¬Éè¼ÆÕߺͿª·¢Õß¿ÉÒÔºÜÈÝÒ×ʹÓÃQML½¨Á¢´øÓÐÁ÷³©¶¯»­µÄÓû§½çÃæ£¬²¢½«ÕâЩ½çÃæÁ¬½Óµ½ºó¶ËµÄC++¿âÉÏÃæ¡£

QMLÊÇÒ»¸öÓû§½Ó¿Ú¹æ·¶ºÍ±à³ÌÓïÑÔ¡£ËüÔÊÐí¿ª·¢ÕߺÍÉè¼ÆÕß´´½¨¸ßÐÔÄܵģ¬Á÷³©µÄ¶¯»­ºÍÊÓ¾õЧ¹ûµÄÓ¦Óá£QMLÌṩÁËÒ»¸ö¸ß¶È¿É¶ÁµÄ£¬ÉùÃ÷ʽµÄ£¬ÀàËÆJSONÓï·¨µÄ£¬²¢Ö§³ÖÓëJavaScript±í´ïʽÏà½áºÏÀ´´ïµ½¶¯Ì¬ÊôÐԵİ󶨡£

ÏîÄ¿Îļþ½á¹¹ÈçÏÂͼ£º

ÏÈ¿´¿´¹¤³ÌÎļþdemo01.pro

TEMPLATE = app
QT += qml quick # ÕâÀïÐèÒªÌí¼ÓqmlºÍquickÄ£¿é
CONFIG += c++11 # c++11±ê×¼Ö§³Ö
SOURCES += main.cpp
RESOURCES += qml.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Additional import path used to resolve QML modules just for Qt Quick Designer
QML_DESIGNER_IMPORT_PATH =
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

main.cpp

#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine; /// QMLÒýÇæ
engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); /// ¼ÓÔØQMLÎļþ
return app.exec();
}

²¹³ä£ºQStringLiteralºê´´½¨Ò»¸öQStringÔÚ±àÒëµÄʱºò£¬Èç¹û±àÒëÆ÷Ö§³ÖÕâÖÖ²Ù×÷¡£Õâ¸öºê±ÜÃâÁËÔËÐÐʱ¶¯Ì¬·ÖÅä¿Õ¼ä¡£

main.qml

QML»ù±¾½éÉÜ

qmlµÄÎļþ½á¹¹·ÖΪÈý²¿·Ö£ºimportÉùÃ÷¡¢¶ÔÏóÉùÃ÷ºÍ×¢ÊÍ¡£

importÉùÃ÷

Ò»¸öQMLÎļþÔÚÎļþ¶¥²¿¿ÉÄܺ¬ÓÐÒ»¸ö»ò¶à¸öimportÉùÃ÷. Ò»¸öimportÉùÃ÷¿ÉÄÜΪÒÔϼ¸ÖÖÀàÐÍ£º

×¢²áµÄÊÇÄĸö°æ±¾µÄÃüÃû¿Õ¼ä¡£

a relative directory which contains type-definitions as QML documents

Ò»¸öJavaScriptÎļþ

JavaScript file imports must be qualified when imported, so that the properties and methods they provide can be accessed.

importÉùÃ÷ÓÐÒÔϼ¸ÖÖÐÎʽ£º

import Namespace VersionMajor.VersionMinor

import Namespace VersionMajor.VersionMinor as SingletonTypeIdentifier

import ¡°directory¡±

import ¡°file.js¡± as ScriptIdentifier

Àý×Ó£º

import QtQuick 2.0
import QtQuick.LocalStorage 2.0 as Database
import "../privateComponents"
import "somefile.js" as Script

¶ÔÏóÉùÃ÷

¶ÔÏóµÄ¼¸¸ö³£ÓÃÊôÐÔ

idÊôÐÔ

QML¶ÔÏóµÄidÊôÐÔÊÇΨһµÄ£¬²»Í¬¶ÔÏóµÄidÊôÐÔÖµ²»ÄÜÏàͬ£¬ÎÒÃÇ¿Éͨ¹ýij¸ö¶ÔÏóµÄidÊôÐÔÀ´·ÃÎÊÕâ¸ö¶ÔÏó¡£idÊôÐÔÊÇQMLÓïÑÔÄÚ½¨µÄÒ»¸öÊôÐÔ£¬ÔÚ¶ÔÏóʵÀý»¯Íê³ÉºóÆäÖµÊDz»Äܱ»Ð޸ĵ쬲»Í¬ÓÚÆäËüµÄÆÕͨÊôÐÔ¡£idÊôÐÔÖµ±ØÐëÒÔСд×Öĸ»òÏ»®Ïß¿ªÍ·£¬ÇÒ²»Äܰüº¬×Öĸ¡¢Êý×Ö¡¢Ï»®ÏßÒÔÍâµÄÆäËü×Ö·û£¬ÈçÏÂËùʾ£º

Rectangle {
id: root
width: 800; height: 480
color: "lightblue"
Column {
Text { id: myText; text: "Hello World" }
Text { text: myText.text }
}
}

ͨ¹ý¶ÔÏóµÄidÀ´·ÃÎÊÕâ¸ö¶ÔÏó£º

×Ô¶¨ÒåÊôÐÔ

ÔÚQMLÎļþÖÐÎÒÃÇ¿É×Ô¶¨ÒåÊôÐÔ£¬Óï·¨ÈçÏ£º

property <propertyType> <propertyName> [ : <value> ]

×Ô¶¨ÒåÊôÐÔÍê³Éºó»á×Ô¶¯ÎªÕâ¸öÊôÐÔ´´½¨Ò»¸öÊôÐÔÖµ¸Ä±äµÄÐźźÍÏàÓ¦µÄÐźŴ¦ÀíÆ÷onChanged£¬ÕâÀïµÄProperNameÊÇÕâ¸öÊôÐÔµÄÃû×Ö£¬Ê××Öĸ´óд£¬ÈçÏÂËùʾ£º

Rectangle {
id: root
property string someText
onSomeTextChanged: console.log("The someText will be: " + someText)
width: 800; height: 480
color: "lightblue"
MouseArea {
anchors.fill: parent
onClicked: someText = "click"
}
}

properNameÒÔÒ»¸öСд×Öĸ¿ªÍ·£¬Ö»ÄܰüÀ¨×Öĸ¡¢Êý×ÖºÍÏ»®Ïß¡£propertyType¿ÉÒÔÊÇQML»ù±¾ÀàÐÍ£¬enumerationÒÔintÀ´´úÌæ£¬Ò²¿ÉÒÔÊÇQML¶ÔÏóÀàÐÍ£¬ÉñÆæµÄvarÀàÐÍÊÇ·µÐ͵ģ¬Ö§³ÖÈκÎÀàÐ͵ÄÊôÐÔÖµ£¬ÈçÏÂËùʾ£º

Item {
property int theNumber
property string theString
property url theUrl
property Item someItem
property Rectangle someRectangle
property var someNumber: 1.5
property var someString: "abc"
property var someBool: true
property var someList: [1, 2, "three", "four"]
property var someObject: Rectangle { width: 100; height: 100; color: "red" }
}

ÊôÐÔÖµ¿ÉÒÔ±»³õʼ»¯£¬Ò²¿ÉÒÔʹÓÃJavaScript±í´ïʽÀ´¸³Öµ£¬Í¨¹ýÕâÁ½ÖÖ·½Ê½¸³ÖµÊ±£¬¿ÉÒÔÊÇÒ»¸ö¾²Ì¬Öµ£¬Ò²¿ÉÒÔÊÇÒ»¸öÓëÆäËüÊôÐ԰󶨵ÄÖµ¡£

Rectangle {
id: rootRect
property color theColor: "green"
property color previousColor: rootRect.color
property color nextColor
width: 100; height: 100
color: "red"
Component.onCompleted: {
rootRect.nextColor = rootRect.color
console.log(theColor, previousColor, nextColor, rootRect.color)
}
}

ÊôÐÔÊÇÀàÐͰ²È«µÄ£¬¸³ÖµÊ±ÊôÐÔÖµ±ØÐëÓëÊôÐÔÀàÐÍÆ¥Å䣬·ñÔò»á³ö´í£¬ÈçÏÂËùʾ£º

// Invalid property assignment: int expected
property int theNumber: "one"

ÁбíÊôÐÔ

ÏÈ¿´ÈçÏ´úÂ룺

Item {
children: [
Text { text: "textOne" },
Text { text: "textTwo" },
Text { text: "textThree" }
]
Component.onCompleted: {
for(var i = 0; i < children.length; i++)
console.log("text of lable", i, ":", children[i].text)
}
}

ÉÏÃæÀý×ÓÖеÄchildrenÊôÐÔ¾ÍÊÇÒ»¸öÁбíÊôÐÔ£¬°üº¬ÔÚÒ»¶Ô·½À¨ºÅÖУ¬ÀïÃæµÄÔªËØ±ØÐëÊÇQML¶ÔÏóÀàÐͶø²»ÄÜÊÇQML»ù±¾ÀàÐÍ£¬²¢ÒÔ¶ººÅ·Ö¸ô¡£ÁбíÄÚµÄÔªËØ¿Éͨ¹ýÊý×éϱê[index]·ÃÎÊ£¬ÔªËظöÊýÓÉlengthÊôÐÔÌṩ¡£ÈôÁбíÄÚÖ»ÓÐÒ»¸öÔªËØ£¬·½À¨ºÅ¿ÉÊ¡ÂÔ¡£

×Ô¶¨ÒåÁбíÊôÐÔ£¬´úÂëÈçÏ£º

Item {
property list<Rectangle> siblingRects
property list<Rectangle> childRects: [
Rectangle { color: "red" },
Rectangle { color: "green" },
Rectangle { color: "blue"}
]
Component.onCompleted: {
for(var i = 0; i < childRects.length; i++)
console.log("color of lable", i, ":", childRects[i].color)
}
}

·Ö×éÊôÐÔ

ÔÚijЩÇé¿öÏ£¬ÊôÐÔ¿ÉÒÔÊÇÓÉÈô¸É¸ö×ÓÊôÐÔ¹¹³ÉµÄÒ»¸öÂß¼­×飬ÎÒÃÇ¿ÉÒÔÓá°.¡±·ûºÅ»òÕß·Ö×é·ûºÅ¶ÔÆä½øÐи³Öµ¡£ Text {

Text {
//dot notation
font.pixelSize: 12
font.bold: true
}
Text {
//group notation
font { pixelSize: 12; bold: true }
}

ÊôÐÔ±ðÃû

ÊôÐÔ±ðÃûÒýÓÃÆäËüµÄÊôÐÔ£¬Óï·¨ÈçÏ£º

[default] property alias <name>: <alias reference>

nameÊÇÎÒÃÇ×Ô¶¨ÒÔµÄÊôÐÔÃû£¬alias referenceÊÇÊôÐÔ±ðÃûËùÒýÓõÄÄǸöÊôÐÔ»ò¶ÔÏó£¬Ò²¾ÍÊÇ˵ÊôÐÔ±ðÃû¿ÉÒÔÒýÓÃ×ÔÒ»¸öµ¥Ò»µÄÊôÐÔ£¬Ò²¿ÉÒÔÒýÓÃ×ÔÒ»¸ö¸´ÔӵĶÔÏó¡£ÊôÐÔ°ó¶¨ÊǶ¯Ì¬µÄ£¬µ«²»ÊÇË«ÏòµÄ£¬¶øÍ¨¹ýÊôÐÔ±ðÃû¿É´ïµ½¶¯Ì¬¡¢Ë«ÏòµÄЧ¹û£¬¼´ÐÞ¸ÄnameºÍaliasreferenceÖÐÈÎÒ»¸öµÄÖµ£¬ÓëÖ®¹ØÁªµÄÁíÒ»¸öÊôÐÔÖµÒ²»áËæÖ®¸Ä±ä¡£»¹ÓÐÒ»µãÐèҪעÒâµÄÊÇ£¬Èç¹ûÊôÐÔ±ðÃûÓëÒÑÓеÄÊôÐÔÃûÏàͬ£¬¾Í»á°ÑÒÑÓеÄÊôÐÔ¸²¸Çµô£¬µ±ÎÒÃÇÔÙʹÓÃÕâ¸öÊôÐÔµÄʱºò£¬Êµ¼ÊÉÏʹÓõÄÊÇÎÒÃÇ×Ô¶¨ÒåµÄÄǸöÊôÐÔ£¬ÈçÏÂËùʾ£º

Rectangle {
id: rootRect
property alias color: blueRect.color
property alias theRect: blueRect
color: "red"
Rectangle {
id: blueRect
color: "#1234ff"
}
Component.onCompleted: {
console.log ("color:", color, // "#1234ff"
"blueRect.color:", blueRect.color, // "#1234ff"
"theRect.color:", theRect.color, // "#1234ff"
"rootRect.color:", rootRect.color) // "#1234ff"
color = "#884646"
console.log ("color:", color, // "#884646"
"blueRect.color:", blueRect.color, // "#884646"
"theRect.color:", theRect.color, // "#884646"
"rootRect.color:", rootRect.color) // "#884646"
blueRect.color = "#123456"
console.log ("color:", color, // "#123456"
"blueRect.color:", blueRect.color, // "#123456"
"theRect.color:", theRect.color, // "#123456"
"rootRect.color:", rootRect.color) // "#123456"
theRect.color = "#ff00ff"
console.log ("color:", color, // "#ff00ff"
"blueRect.color:", blueRect.color, // "#ff00ff"
"theRect.color:", theRect.color, // "#ff00ff"
"rootRect.color:", rootRect.color) // "#ff00ff"
}
}

ĬÈÏÊôÐÔ

ÈκλùÓÚItemµÄÀàÐͶ¼ÓÐÒ»¸ödataÁбíÊôÐÔ£¬Õâ¸öÊôÐÔ¾ÍÊǸÃÀàÐ͵ÄĬÈÏÊôÐÔ£¬±£´æÁËËùÓеĺ¢×Ó¶ÔÏ󣬯äÖпÉÊӵĺ¢×Ó¶ÔÏóÓÖ±£´æÔÚÁËchildrenÁбíÊôÐÔÖУ¬²»¿ÉÊӵĺ¢×Ó¶ÔÏó±£´æÔÚÁËresourcesÁбíÊôÐÔÖУ¬ÔÚÌí¼Ó×Ó¶ÔÏóʱchildren¡¢resourcesÊôÐÔ¿Éд¿É²»Ð´£¬¶¼»á×Ô¶¯Ìí¼Óµ½¶ÔÓ¦µÄÊôÐÔÁбíÖУ¬ËùÒÔÔÚ֮ǰ½éÉÜÁбíÊôÐÔµÄÀý×ÓÖпÉÊ¡ÂÔchildren¹Ø¼ü×Ö£¬Ð޸ĺóÈçÏ£º

Item {
Text { text: "textOne" }
Text { text: "textTwo" }
Text { text: "textThree" }
Component.onCompleted: {
for(var i = 0; i < children.length; i++)
console.log("text of lable", i, ":", children[i].text)
}
}

ÁíÍ⣬ÎÒÃÇ»¹¿ÉÒÔÔÚ×Ô¶¨ÒåÊôÐÔʱÌí¼Ódefault¹Ø¼ü×Ö£¬½«Õâ¸öÊôÐÔ×÷ΪĬÈÏÊôÐÔ¡£

Ö»¶ÁÊôÐÔ

ʹÓÃreadonly¹Ø¼ü×ֿɶ¨ÒåÒ»¸öÖ»¶ÁÊôÐÔ£¬Óï·¨ÈçÏ£º

readonly property <propertyType> <propertyName> : <initialValue>

Ö»¶ÁÊôÐÔ±ØÐë³õʼ»¯£¬ÇÒ²»ÄÜÐ޸ģ¬Ò²²»ÄÜÊÇdefaultÊôÐÔºÍaliasÊôÐÔ£¬ÈçÏÂËùʾ£º

Item {
readonly property int someNumber: 10
Component.onCompleted: someNumber = 20 // TypeError: Cannot assign to read-only property "someNumber"
}

¸½¼ÓÊôÐÔ

QMLÓïÑÔ»¹°üÀ¨ÁËһЩ¸½¼ÓÊôÐÔºÍÐźŴ¦ÀíÆ÷£¬ÓÉÏàÓ¦µÄ¸½¼ÓÀàÐÍÌṩ£¬Ê¹ÓÃÓï·¨ÈçÏ£º

<AttachingType>.<propertyName>
<AttachingType>.on<SignalName>

anchorsê²¼¾Ö

QMLµÄ²¼¾Ö·½Ê½Ò»°ã²ÉÓÃÁ½ÖÖ£¬Ò»ÖÖ¾ÍÊÇÖ±½ÓÉèÖã¬XÓëY×ø±êµÄÖµ¡£Ò»ÖÖÊDzÉÓÃÏà¶ÔλÖò¼¾Ö£¬anchorsê²¼¾Ö¡£Ê¹ÓÃê²¼¾ÖµÄÄܹ»Ê¹½çÃæ¸ü½ô´Õ£¬¸üÓÐÕûÌ廯¡£Ãª²¼¾ÖÏ൱ÓÚQtµÄ Grid£¬HBox£¬VBox layout¡£

ê²¼¾Ö°üº¬Æ÷¸öÊôÐÔ£ºleft, horizontalCenter, right, top, verticalCenter, baseline, and bottom.

The Qt Quick anchoring system allows you to define relationships between the anchor lines of different items. For example, you can write:

Rectangle { id: rect1; ... }
Rectangle { id: rect2; anchors.left: rect1.right; ... }

You can specify multiple anchors. For example:

Rectangle { id: rect1; ... }
Rectangle { id: rect2; anchors.left: rect1.right; anchors.top: rect1.bottom; ... }

By specifying multiple horizontal or vertical anchors you can control the size of an item. Below, rect2 is anchored to the right of rect1 and the left of rect3. If either of the blue rectangles are moved, rect2 will stretch and shrink as necessary:

Rectangle { id: rect1; x: 0; ... }
Rectangle { id: rect2; anchors.left: rect1.right; anchors.right: rect3.left; ... }
Rectangle { id: rect3; x: 150; ... }

ê²¼¾ÖµÄMarginsºÍOffsets

Rectangle { id: rect1; ... }
Rectangle { id: rect2; anchors.left: rect1.right; anchors.leftMargin: 5; ... }

2×¢Ò⣺´¦ÓÚÐÔÄÜÔ­Òò£¬Äã½ö±»ÔÊÐíÏà¶ÔËüµÄÐֵܶÔÏó»òÕ߸¸¶ÔÏóÀ´Ãª¶¨Ò»¸ö¶ÔÏó¡£

´úÂë

import QtQuick 2.6
import QtQuick.Window 2.2
/*
Window¶ÔÏóΪQt Quick ÊÓ´°´´½¨Ò»¸ö¶¥²ãµÄ´°¿Ú.
ҪʹÓÃÕâ¸ö¶ÔÏ󣬱ØÐëÔö¼ÓÈçÏÂimportÉùÃ÷£º
import QtQuick.Window 2.2
*/
Window {
visible: true // ÊÇ·ñ¿É¼û
width: 640
height: 480
title: qsTr("Hello World")
/*
MouseAreaÊÇÒ»¸ö²»¿É¼ûµÄ¶ÔÏó£¬Í¨³£ÓÃÀ´¹ØÁªÒ»¸ö¿É¼ûµÄ¶ÔÏó£¬ÒÔ±ãΪËüÌṩÊó±ê²Ù×÷¡£
*/
MouseArea {
/*
anchors.centerIn:parent,Êǽ«×ӿؼþ·ÅÔÚ¸¸¿Ø¼þµÄÕýÖÐÐÄ£¬×ӿؼþµÄ¿í¸ßÊÇ×Ô¼ºÉèÖõģ»anchors.fill£ºparent, ÊÇÔÚ×ӿؼþµÄ´óСÉèÖÃÓ븸¿Ø¼þ´óСһÑù£¬ÌرðÊÇmouseAreaÖо­³£Ê¹ÓÃanchors.fill£ºparent£¬ÕâÊÇΪÁËÖ¸¶¨Êó±êʼþ½ÓÊܵķ¶Î§¡£Èç¹ûÊÇÁ½¸ö¾ØÐοؼþ£¬ÑÕÉ«²»Í¬£¬ÄÇô×ӿؼþ»áÍêÈ«¸²¸Ç¸¸¿Ø¼þ£¬È«ÊÇ×ӿؼþµÄÑÕÉ«ÏÔʾ¡£
»¹ÓÐÒ»µã£¬¾ÍÊÇparentÊÇÖ¸¸¸Àֱ࣬½ÓÏà¹ØµÄ¸¸Àà¡£anchors.fillÖ¸¶¨µÄ¸¸ÀàÊDZØÐëÊÇÖ±½ÓµÄ¸¸À࣬Èç¹û²»ÊÇ£¬»á±¨´íµÄ¡£
*/
anchors.fill: parent
/*
Êó±êλÖÃÐÅÏ¢ºÍ°´¼üµã»÷ʼþͨ¹ýsignalsÌṩ.ʹÓÃÆµÂÊ×î¸ßµÄÊó±ê°´Ïº͵ã»÷´¦Àíʼþ£ºonClicked, onDoubleClicked, onPressed, onReleased and onPressAndHold.
»¹¿ÉÒÔʹÓÃonWheelÐźÅÈ¥²Ù×÷Ëܱê¹ö¶¯Ê¼þ¡£
*/
onClicked: {
/*
console.log, console.debug, console.info, console.warnºÍconsole.error¿ÉÒÔ±»ÓÃÀ´´òÓ¡µ÷ÊÔÐÅÏ¢µ½¿ØÖÆÌ¨ÉÏ.
*/
console.log(qsTr('Clicked on background. Text: "' + textEdit.text + '"'))
}
}
TextEdit {
/*
IDÊôÐÔ£º
QML¶ÔÏóµÄidÊôÐÔÊÇΨһµÄ£¬²»Í¬¶ÔÏóµÄidÊôÐÔÖµ²»ÄÜÏàͬ£¬ÎÒÃÇ¿Éͨ¹ýij¸ö¶ÔÏóµÄidÊôÐÔÀ´·ÃÎÊÕâ¸ö¶ÔÏó¡£
idÊôÐÔÊÇQMLÓïÑÔÄÚ½¨µÄÒ»¸öÊôÐÔ£¬ÔÚ¶ÔÏóʵÀý»¯Íê³ÉºóÆäÖµÊDz»Äܱ»Ð޸ĵ쬲»Í¬ÓÚÆäËüµÄÆÕͨÊôÐÔ¡£
idÊôÐÔÖµ±ØÐëÒÔСд×Öĸ»òÏ»®Ïß¿ªÍ·£¬ÇÒ²»Äܰüº¬×Öĸ¡¢Êý×Ö¡¢Ï»®ÏßÒÔÍâµÄÆäËü×Ö·û¡£
*/
id: textEdit
text: qsTr("Enter some text...")
/*
horizontalAlignmentºÍverticalAlignment¡£
Valid values for horizontalAlignment are:
TextEdit.AlignLeft (default)
TextEdit.AlignRight
TextEdit.AlignHCenter
TextEdit.AlignJustify
Valid values for verticalAlignment are:
TextEdit.AlignTop (default)
TextEdit.AlignBottom
TextEdit.AlignVCenter
*/
verticalAlignment: Text.AlignVCenter
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: 20
Rectangle {
anchors.fill: parent
anchors.margins: -10
color: "transparent"
border.width: 1
}
}
}
   
2669 ´Îä¯ÀÀ       29
Ïà¹ØÎÄÕÂ

Éî¶È½âÎö£ºÇåÀíÀôúÂë
ÈçºÎ±àд³öÓµ±§±ä»¯µÄ´úÂë
ÖØ¹¹-ʹ´úÂë¸ü¼ò½àÓÅÃÀ
ÍŶÓÏîÄ¿¿ª·¢"±àÂë¹æ·¶"ϵÁÐÎÄÕÂ
Ïà¹ØÎĵµ

ÖØ¹¹-¸ÄÉÆ¼ÈÓдúÂëµÄÉè¼Æ
Èí¼þÖØ¹¹v2
´úÂëÕû½àÖ®µÀ
¸ßÖÊÁ¿±à³Ì¹æ·¶
Ïà¹Ø¿Î³Ì

»ùÓÚHTML5¿Í»§¶Ë¡¢Web¶ËµÄÓ¦Óÿª·¢
HTML 5+CSS ¿ª·¢
ǶÈëʽC¸ßÖÊÁ¿±à³Ì
C++¸ß¼¶±à³Ì