Skip to content

Commit fa3cbe8

Browse files
committed
Add QmlColorDialog
1 parent f4915a8 commit fa3cbe8

File tree

7 files changed

+81
-0
lines changed

7 files changed

+81
-0
lines changed

QmlColorDialog/QmlColorDialog.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

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

QmlColorDialog/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+
id: root
15+
visible: true
16+
width: 400
17+
height: 300
18+
title: qsTr("Qml选择颜色对话框")
19+
color: colorDialog.color
20+
21+
Button{
22+
text: qsTr("选择颜色")
23+
height: 48
24+
width: 120
25+
anchors.centerIn: parent
26+
MouseArea{
27+
anchors.fill: parent
28+
onClicked: {
29+
colorDialog.open();
30+
}
31+
}
32+
}
33+
34+
ColorDialog {
35+
id: colorDialog
36+
title: qsTr("选择颜色")
37+
color: "#AAAAAA"
38+
}
39+
}

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

QmlColorDialog/show.gif

123 KB
Loading

QtQuickExamples.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@ SUBDIRS += QmlPageNavigation
4444
SUBDIRS += QmlUpDownRefresh
4545
SUBDIRS += QmlListViewDragDrop
4646
SUBDIRS += QmlCanvasWaveProgress
47+
SUBDIRS += QmlColorDialog

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,11 @@ QmlCanvasWaveProgress: Qml圆形波浪进度条
207207
![](https://github.com/zhengtianzuo/QtQuickExamples/blob/master/QmlCanvasWaveProgress/show.gif?raw=true)
208208

209209

210+
QmlColorDialog: Qml选择颜色对话框
211+
212+
![](https://github.com/zhengtianzuo/QtQuickExamples/blob/master/QmlColorDialog/show.gif?raw=true)
213+
214+
210215

211216

212217
***

0 commit comments

Comments
 (0)