FontLoader
ImportStatement: import QtQuick 2.2
Properties
name :string
source : url
status :enumeration
DetailedDescription
通过名称或URL加载字体。
status是字体加载的状况,对加载远程字体是有用的。
例如:
importQtQuick 2.0
Column {
FontLoader { id: fixedFont; name:"Courier" }
FontLoader { id: webFont; source:"http://www.mysite.com/myfont.ttf" }
Text { text: "Fixed-size font";font.family: fixedFont.name }
Text { text: "Fancy font";font.family: webFont.name }
}
Property Documentation
name :string
加载的字体的名字,当使用url属性加载字体时,它自动设置。这个属性用于设置Text组件的font.family属性。
例如:
Item {
width: 200; height: 50
FontLoader {
id: webFont
source:"http://www.mysite.com/myfont.ttf"
}
Text {
text: "Fancy font"
font.family: webFont.name
}
}
source : url
加载字体的URL
status :enumeration
字体加载的情况,它是下面的值之一:
FontLoader.Null- 没有字体被设置
FontLoader.Ready- 字体加载完毕
FontLoader.Loading- 字体正在被加载
FontLoader.Error- 加载字体发生错误
用一些方式处理状态的变化,例如:
触发状态改变:
State {name: 'loaded'; when: loader.status == FontLoader.Ready }
实现onStatusChanged信号处理:
FontLoader {
id: loader
onStatusChanged: if (loader.status ==FontLoader.Ready) console.log('Loaded')
}
绑定状态值:
Text { text: loader.status == FontLoader.Ready ?'Loaded' : 'Not loaded' }
本文详细介绍了Qt中FontLoader组件的使用方法及其属性。FontLoader可以用来通过名称或URL加载字体,并提供了字体加载状态的反馈。文章通过示例展示了如何在Qt应用中配置和使用FontLoader。
915

被折叠的 条评论
为什么被折叠?



