Qml获取字体列表

来源:互联网 发布:vfp编程 编辑:程序博客网 时间:2024/05/16 07:01

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

原创粉丝点击