Skip to content

Commit 318a76d

Browse files
committed
Add QmlChartView
1 parent 6bc37a9 commit 318a76d

File tree

7 files changed

+91
-1
lines changed

7 files changed

+91
-1
lines changed

QmlChartView/QmlChartView.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 charts
8+
9+
CONFIG += c++11
10+
11+
SOURCES += main.cpp
12+
13+
RESOURCES += qml.qrc

QmlChartView/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+
}

QmlChartView/main.qml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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 QtCharts 2.2
11+
12+
ApplicationWindow {
13+
visible: true
14+
width: 400
15+
height: 300
16+
title: qsTr("Qml饼状图")
17+
18+
ChartView {
19+
anchors.fill: parent
20+
theme: ChartView.ChartThemeQt
21+
antialiasing: true
22+
legend.visible: false
23+
animationOptions: ChartView.AllAnimations
24+
25+
PieSeries {
26+
id: pieSeries
27+
PieSlice {
28+
borderColor: "#AAAAAA"
29+
color: "#804040"
30+
label: qsTr("整形")
31+
labelVisible: true
32+
value: 66.6
33+
}
34+
PieSlice {
35+
borderColor: "#AAAAAA"
36+
color: "#408040"
37+
label: qsTr("字符串")
38+
labelVisible: true
39+
value: 30
40+
}
41+
PieSlice {
42+
borderColor: "#AAAAAA"
43+
color: "#404080"
44+
label: qsTr("文件")
45+
labelVisible: true
46+
value: 3.4
47+
}
48+
}
49+
}
50+
}

QmlChartView/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>

QmlChartView/show.gif

81.8 KB
Loading

QtQuickExamples.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ SUBDIRS += QmlCanvasWaveProgress
4747
SUBDIRS += QmlColorDialog
4848
SUBDIRS += QmlFileDialog
4949
SUBDIRS += QmlFontDialog
50-
50+
SUBDIRS += QmlChartView

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ QmlFontDialog: Qml字体选择对话框
222222
![](https://github.com/zhengtianzuo/QtQuickExamples/blob/master/QmlFontDialog/show.gif?raw=true)
223223

224224

225+
QmlChartView: Qml饼状图
226+
227+
![](https://github.com/zhengtianzuo/QtQuickExamples/blob/master/QmlChartView/show.gif?raw=true)
228+
225229

226230

227231

0 commit comments

Comments
 (0)