惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tenable Blog
Last Week in AI
Last Week in AI
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
H
Help Net Security
F
Fortinet All Blogs
MyScale Blog
MyScale Blog
宝玉的分享
宝玉的分享
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 司徒正美
量子位
N
Netflix TechBlog - Medium
Apple Machine Learning Research
Apple Machine Learning Research
小众软件
小众软件
Recorded Future
Recorded Future
博客园 - 三生石上(FineUI控件)
Vercel News
Vercel News
aimingoo的专栏
aimingoo的专栏
I
InfoQ
Microsoft Security Blog
Microsoft Security Blog
Scott Helme
Scott Helme
The Last Watchdog
The Last Watchdog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家
AI
AI
WordPress大学
WordPress大学
Security Archives - TechRepublic
Security Archives - TechRepublic
Google Online Security Blog
Google Online Security Blog
U
Unit 42
V2EX - 技术
V2EX - 技术
MongoDB | Blog
MongoDB | Blog
Schneier on Security
Schneier on Security
博客园 - Franky
H
Heimdal Security Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Jina AI
Jina AI
W
WeLiveSecurity
P
Privacy & Cybersecurity Law Blog
Cloudbric
Cloudbric
B
Blog RSS Feed
N
News | PayPal Newsroom
S
Securelist
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
I
Intezer
Hacker News - Newest:
Hacker News - Newest: "LLM"
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
博客园_首页
罗磊的独立博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More
雷峰网
雷峰网

博客园 - 蚂蚁跳楼

博文阅读密码验证 - 博客园 qt 的视频教程 sed 使用 qt dbus 的一入门文章 qt越来越好了 ubuntu - 中文 qt-creator astyle Peizhi qml中打开本地html 捷豹汽车的车载系统 博文阅读密码验证 - 博客园 转一个文章:在腾讯的第一堂产品课 QML的一些基础的区分 qml的一个文章----可以看出状态、动画的使用 博文阅读密码验证 - 博客园 凡是人性的,都是如下的 全国经纬度,具体到县 web-nodkit 入门 一个文章-转年收入50万美元的软件工程师做的是什么类型的工作 一个基于qml的网络封装库
qml 封装技巧-利用数据来进行适配
蚂蚁跳楼 · 2015-05-14 · via 博客园 - 蚂蚁跳楼

Text属于用的频率比较高而且需要定义的地方又比较多的地方,看一下如下的把Text封装成Label进行使用。

使用的例子:
Label {
id: titleLabel

anchors {
left: parent.left
right: parent.right
margins: units.dp(16)
}

style: "title"
text: "Edit info"
}

封装的原始代码:

import QtQuick 2.0

Text {
id: label
property string style: "body1"

property var fontStyles: {
"display4": {
"size": 112,
"font": "light"
},

"display3": {
"size": 56,
"font": "regular"
},

"display2": {
"size": 45,
"font": "regular"
},

"display1": {
"size": 34,
"font": "regular"
},

"headline": {
"size": 24,
"font": "regular"
},

"title": {
"size": 20,
"font": "medium"
},

"dialog": {
"size": 18,
"size_desktop": 17,
"font": "regular"
},

"subheading": {
"size": 16,
"size_desktop": 15,
"font": "regular"
},

"body2": {
"size": 14,
"size_desktop": 13,
"font": "medium"
},

"body1": {
"size": 14,
"size_desktop": 13,
"font": "regular"
},

"caption": {
"size": 12,
"font": "regular"
},

"menu": {
"size": 14,
"size_desktop": 13,
"font": "medium"
},

"button": {
"size": 14,
"font": "medium"
},

"tooltip": {
"size_desktop": 10,
"size": 14,
"font": "medium"
}
}

property var fontInfo: fontStyles[style]

font.pixelSize: units.dp(!Device.isMobile && fontInfo.size_desktop
? fontInfo.size_desktop : fontInfo.size)
font.family: "Roboto"
font.weight: {
var weight = fontInfo.font

if (weight === "medium") {
return Font.DemiBold
} else if (weight === "regular") {
return Font.Normal
} else if (weight === "light") {
return Font.Light
}
}

font.capitalization: style == "button" ? Font.AllUppercase : Font.MixedCase

color: Theme.light.textColor

}