当前位置:网站首页>2.1.1 QML grammar foundation I
2.1.1 QML grammar foundation I
2022-06-24 07:32:00 【Code xiansen】
import QtQuick 2.9
Rectangle{
id:root
width:400
height:400
color:"blue"
Image{
source:"img/hi.png"
anchor.centerIn:parent
}
}1. Import statement
import QtQuick 2.9 : Imported QtQuick modular , Including all kinds of QML type , If not used import sentence ,Rectangle and Image Types cannot be used
2. Objects and properties
In the above code , We created Rectangle Root object and Image Sub object .QML Objects start with a capital letter , There is a pair of curly braces behind it , The brackets contain the... Of the object id、 Attribute value or sub object .
An object usually specifies a at the beginning id, This id It's here qml It has to be the only one . We can go through id Value identifies and references this object in other objects , but id The property of a value is not an attribute .
except id Set up , stay Rectangle It also sets width、height and color Equal attribute , Property through “ attribute : value ” Syntax to initialize , Property and its value are separated by colons .
When attributes can be written separately , No semicolon at the end ; Attribute values are written on one line , Must be separated by semicolons .
3. Layout
anchor.centerIn It belongs to anchor layout
4. expression
Item{
id:root
width:text1.width+30
Text{
id:text1
width:30
}
}Include references to other objects or attributes in the expression , When the value of the expression changes is , Properties that take this expression as a value are automatically updated to the new value .
5. Printout
console.log() and console.debug() To output debugging information , similar qt C++ Medium qDebug()
6.import Import statement
import QtQuick 2.9 as CoreItems
import "../textwidgets" as Mymodule
CoreItems.Rectangle{
width:100;height:100
MyMudule.Text{ text:"Hello Qt!"}
CoreItems.Text{text:"Hello from Qt Quick"}
}(1) If QtQuick And custom Mymodule There are Text type , In the same Qml These two modules are used in , You need to add as Qualifier after
(2) Add the upper bound qualifier , Use any object preceded by a qualifier
边栏推荐
- Huawei cloud image engine service
- [cnpm] tutorial
- (CVE-2020-11978)Airflow dag中的命令注入漏洞复现【vulhub靶场】
- [image fusion] image fusion based on NSST and PCNN with matlab code
- Actual target shooting - skillfully use SMB to take down the off-line host
- Canal installation configuration
- How to select a third-party software testing company? 2022 ranking of domestic software testing institutions
- How VPN works
- 相机标定(标定目的、原理)
- 【图像特征提取】基于脉冲耦合神经网络(PCNN)实现图像特征提取含Matlab源码
猜你喜欢

与(&&)逻辑或(||),动态绑定结合三目运算

JVM debugging tool -jmap

【Proteus】Arduino UNO + DS1307+LCD1602时间显示

How to delete / select an input method on your computer

華為雲數據庫進階學習
![[OGeek2019]babyrop](/img/74/5f93dcee9ea5a562a7fba5c17aab76.png)
[OGeek2019]babyrop

【图像融合】基于伪 Wigner 分布 (PWD) 实现图像融合附matlab代码

蓝牙耳机怎么连接电脑使用,win10电脑如何连接蓝牙耳机

Learning to use BACnet gateway of building control system is not so difficult

20 not to be missed ES6 tips
随机推荐
Cisco router configuration notes: static routing, rip, OSPF, principles combined with experiments, worth a visit!
[image fusion] image fusion based on directional discrete cosine transform and principal component analysis with matlab code
[MRCTF2020]千层套路
Prefix and topic training
2、 What is the principle of layer 3 and 4 switching technology? Recommended collection!
[wustctf2020] climb
与(&&)逻辑或(||),动态绑定结合三目运算
软件性能测试分析与调优实践之路-JMeter对RPC服务的性能压测分析与调优-手稿节选
【图像特征提取】基于脉冲耦合神经网络(PCNN)实现图像特征提取含Matlab源码
[pointnet] matlab simulation of 3D point cloud target classification and recognition based on pointnet
Virtual machine security disaster recovery construction
[image segmentation] retinal vessel segmentation based on morphology with matlab code
Win11 points how to divide disks? How to divide disks in win11 system?
Hubei College Upgraded to undergraduate - Hushi family planning department
What is automated testing? What software projects are suitable for automated testing?
bjdctf_ 2020_ babystack
[WUSTCTF2020]爬
[WordPress website] 6 Article content copy prevention
Precipitation of architecture design methodology
MaxCompute远程连接,上传、下载数据文件操作