• 2674阅读
  • 0回复

zhengtianzuo系列-Qml获取字体列表 [复制链接]

上一主题 下一主题
离线zhengtianzuo
 

只看楼主 倒序阅读 楼主  发表于: 2017-10-28
qml中使用Qt.fontFamilies()可以返回字体的列表, 我们用一个ListView显示出来

```
ListView{
        id: comb
        anchors.fill: parent
        model: Qt.fontFamilies()
        delegate: Item {
            height: 32
            width: parent.width

            Rectangle{
                id: fontSelect
                height: 24
                width: parent.width

                Text {
                    id: txtShow
                    anchors.left: parent.left
                    anchors.leftMargin: 6
                    verticalAlignment: Text.AlignVCenter
                    text: qsTr("Select Font 选择字体")
                    font.family: modelData
                    font.pixelSize: 14
                }

                Text {
                    id: txtFont
                    anchors.left: txtShow.right
                    anchors.leftMargin: 6
                    anchors.verticalCenter: txtShow.verticalCenter
                    verticalAlignment: Text.AlignVCenter
                    text: modelData
                    font.pixelSize: 14
                }
            }

            Rectangle {
                height: 2
                width: parent.width
                anchors.top: fontSelect.bottom
                color: "#148014"
            }

            MouseArea{
                anchors.fill: parent
                onClicked: {
                    emit: sClick(modelData);
                    fontList.visible = false;
                }
            }
        }
    }
```



需要完整代码请访问 QtQuickExamples
博客地址: https://blog.csdn.net/zhengtianzuo06
Github: https://github.com/zhengtianzuo
个人产品: https://github.com/zhengtianzuo/Silk
产品网站: http://www.camelstudio.cn
快速回复
限100 字节
 
上一个 下一个