QML类型说明-FontLoader

来源:互联网 发布:synthesia mac 编辑:程序博客网 时间:2024/06/06 13:12

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' }
0 0
原创粉丝点击