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

推荐订阅源

美团技术团队
D
DataBreaches.Net
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
D
Docker
N
Netflix TechBlog - Medium
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
Check Point Blog
腾讯CDC
Stack Overflow Blog
Stack Overflow Blog
V
Visual Studio Blog
IT之家
IT之家
月光博客
月光博客
U
Unit 42
K
Kaspersky official blog
T
Threatpost
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
GbyAI
GbyAI
P
Proofpoint News Feed
Last Week in AI
Last Week in AI
云风的 BLOG
云风的 BLOG
酷 壳 – CoolShell
酷 壳 – CoolShell
I
InfoQ
Engineering at Meta
Engineering at Meta
Recorded Future
Recorded Future
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Security @ Cisco Blogs
MyScale Blog
MyScale Blog
大猫的无限游戏
大猫的无限游戏
Security Archives - TechRepublic
Security Archives - TechRepublic
Webroot Blog
Webroot Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Hacker News - Newest:
Hacker News - Newest: "LLM"
S
Schneier on Security
S
Secure Thoughts
The Register - Security
The Register - Security
B
Blog RSS Feed
The Last Watchdog
The Last Watchdog
P
Palo Alto Networks Blog
爱范儿
爱范儿
B
Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
N
News and Events Feed by Topic
阮一峰的网络日志
阮一峰的网络日志
L
LINUX DO - 热门话题
C
Cisco Blogs
Spread Privacy
Spread Privacy
F
Full Disclosure
博客园 - 聂微东
T
The Blog of Author Tim Ferriss

博客园 - 蚂蚁跳楼

博文阅读密码验证 - 博客园 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

}