Skip to content

Commit 71628d4

Browse files
committed
Add QmlFontDialog
1 parent 2e96ae8 commit 71628d4

File tree

7 files changed

+82
-0
lines changed

7 files changed

+82
-0
lines changed

QmlFontDialog/QmlFontDialog.pro

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#-------------------------------------------------
2+
#
3+
# Copyright (C) 2003-2103 CamelSoft Corporation
4+
#
5+
#-------------------------------------------------
6+
7+
QT += qml quick widgets
8+
9+
CONFIG += c++11
10+
11+
SOURCES += main.cpp
12+
13+
RESOURCES += qml.qrc

QmlFontDialog/main.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*!
2+
*@file main.cpp
3+
*@brief 程序主文件
4+
*@version 1.0
5+
*@section LICENSE Copyright (C) 2003-2103 CamelSoft Corporation
6+
*@author zhengtianzuo
7+
*/
8+
#include <QApplication>
9+
#include <QQmlApplicationEngine>
10+
11+
int main(int argc, char *argv[])
12+
{
13+
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
14+
QApplication app(argc, argv);
15+
QQmlApplicationEngine engine;
16+
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
17+
return app.exec();
18+
}

QmlFontDialog/main.qml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*!
2+
*@file main.qml
3+
*@brief 主文件
4+
*@version 1.0
5+
*@section LICENSE Copyright (C) 2003-2103 CamelSoft Corporation
6+
*@author zhengtianzuo
7+
*/
8+
import QtQuick 2.7
9+
import QtQuick.Controls 2.0
10+
import QtQuick.Layouts 1.0
11+
import Qt.labs.platform 1.0
12+
13+
ApplicationWindow {
14+
visible: true
15+
width: 400
16+
height: 300
17+
title: qsTr("Qml字体选择对话框")
18+
19+
Button{
20+
anchors.centerIn: parent
21+
height: 48
22+
width: 120
23+
text: qsTr("打开")
24+
MouseArea{
25+
anchors.fill: parent
26+
onClicked: {
27+
fontDialog.open()
28+
}
29+
}
30+
}
31+
32+
FontDialog {
33+
id: fontDialog
34+
onAccepted: {
35+
console.debug(qsTr("选择的字体名称是: ") + fontDialog.currentFont.family)
36+
console.debug(qsTr("选择的字体大小是: ") + fontDialog.currentFont.pointSize)
37+
}
38+
}
39+
}

QmlFontDialog/qml.qrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<RCC>
2+
<qresource prefix="/">
3+
<file>main.qml</file>
4+
</qresource>
5+
</RCC>

QmlFontDialog/show.gif

115 KB
Loading

QtQuickExamples.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,5 @@ SUBDIRS += QmlListViewDragDrop
4646
SUBDIRS += QmlCanvasWaveProgress
4747
SUBDIRS += QmlColorDialog
4848
SUBDIRS += QmlFileDialog
49+
SUBDIRS += QmlFontDialog
4950

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,12 @@ QmlFileDialog: Qml文件对话框
217217
![](https://github.com/zhengtianzuo/QtQuickExamples/blob/master/QmlFileDialog/show.gif?raw=true)
218218

219219

220+
QmlFontDialog: Qml字体选择对话框
221+
222+
![](https://github.com/zhengtianzuo/QtQuickExamples/blob/master/QmlFontDialog/show.gif?raw=true)
223+
224+
225+
220226

221227

222228
***

0 commit comments

Comments
 (0)