zhengtianzuo |
2017-10-28 13:42 |
zhengtianzuo系列-Qml获取字体列表
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 |
|