当前位置:网站首页>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
边栏推荐
- In the era of industrial Internet, there are no more centers in the real sense, and these centers just turn tangible into intangible
- 电脑如何打开软键盘,教大家Win10如何打开软键盘的方法
- [OGeek2019]babyrop
- A case of bouncing around the system firewall
- JVM debugging tool -jmap
- 華為雲數據庫進階學習
- Ultra wideband pulse positioning scheme, UWB precise positioning technology, wireless indoor positioning application
- Deploy loglistener in tke container to collect logs to CLS
- [image segmentation] retinal vessel segmentation based on morphology with matlab code
- How to delete / select an input method on your computer
猜你喜欢

Win11笔记本省电模式怎么开启?Win11电脑节电模式打开方法

Camera calibration (calibration purpose and principle)

Huawei Cloud Database Advanced Learning

20个不容错过的ES6技巧
![[tips] use the deep learning toolbox of MATLAB deepnetworkdesigner to quickly design](/img/74/f615191715a9ac58a8546f8d1e8f8d.png)
[tips] use the deep learning toolbox of MATLAB deepnetworkdesigner to quickly design

简单使用Modbus转BACnet网关教程

【图像融合】基于方向离散余弦变换和主成分分析的图像融合附matlab代码

More than 60 million shovel excrement officials, can they hold a spring of domestic staple food?

PIP install XXX on the terminal but no module named XXX on pycharm
![[signal recognition] signal modulation classification based on deep learning CNN with matlab code](/img/0b/7475cd4cf2ddce912816ab3c29b914.png)
[signal recognition] signal modulation classification based on deep learning CNN with matlab code
随机推荐
Buuctf misc grab from the doll
MFC多线程 信号量CSemaphore 临界区与互斥 事件
超宽带脉冲定位方案,UWB精准定位技术,无线室内定位应用
[从零开始学习FPGA编程-42]:视野篇 - 后摩尔时代”芯片设计的技术演进-1-现状
【图像融合】基于像素显着性结合小波变换实现多焦点和多光谱图像融合附matlab代码
RDD基础知识点
[MRCTF2020]千层套路
PCL 计算多边形的面积
[WordPress website] 5 Set code highlight
jarvisoj_ level2
(CVE-2020-11978)Airflow dag中的命令注入漏洞复现【vulhub靶场】
[tips] use the deep learning toolbox of MATLAB deepnetworkdesigner to quickly design
[DDCTF2018](╯°□°)╯︵ ┻━┻
Intranet learning notes (4)
Precipitation of architecture design methodology
[WUSTCTF2020]alison_likes_jojo
[cnpm] tutorial
[learn FPGA programming from scratch -42]: Vision - technological evolution of chip design in the "post Moorish era" - 1 - current situation
[image fusion] image fusion based on pseudo Wigner distribution (PWD) with matlab code
如何删除/选择电脑上的输入法