File tree Expand file tree Collapse file tree 9 files changed +140
-0
lines changed Expand file tree Collapse file tree 9 files changed +140
-0
lines changed Original file line number Diff line number Diff line change
1
+ # -------------------------------------------------
2
+ #
3
+ # Copyright (C) 2003-2103 CamelSoft Corporation
4
+ #
5
+ # -------------------------------------------------
6
+
7
+ QT += qml quick
8
+
9
+ CONFIG += c++11
10
+
11
+ SOURCES += main.cpp
12
+
13
+ RESOURCES += qml.qrc
Original file line number Diff line number Diff line change
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 < QGuiApplication>
9
+ #include < QQmlApplicationEngine>
10
+
11
+ int main (int argc, char *argv[])
12
+ {
13
+ QCoreApplication::setAttribute (Qt::AA_EnableHighDpiScaling);
14
+ QGuiApplication app (argc, argv);
15
+
16
+ QQmlApplicationEngine engine;
17
+ engine.load (QUrl (QLatin1String (" qrc:/main.qml" )));
18
+ if (engine.rootObjects ().isEmpty ())
19
+ return -1 ;
20
+
21
+ return app.exec ();
22
+ }
Original file line number Diff line number Diff line change
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
+
11
+ ApplicationWindow {
12
+ id: root
13
+ visible: true
14
+ width: 400
15
+ height: 400
16
+ title: qsTr (" Qml翻转效果" )
17
+
18
+ Flipable{
19
+ id: flip
20
+ width: 300
21
+ height: 300
22
+ anchors .centerIn : parent
23
+
24
+ property bool flipped: false
25
+
26
+ front: Image{
27
+ anchors .fill : parent
28
+ source: " qrc:/images/1.jpg"
29
+ }
30
+
31
+ back: Image{
32
+ anchors .fill : parent
33
+ source: " qrc:/images/2.jpg"
34
+ }
35
+
36
+ transform: Rotation{
37
+ id: rotation
38
+ origin .x : flip .width / 2
39
+ origin .y : flip .height / 2
40
+ axis .x : rx .checked
41
+ axis .y : ry .checked
42
+ axis .z : rz .checked
43
+ angle: 0
44
+ }
45
+
46
+ states: State{
47
+ PropertyChanges {
48
+ target: rotation
49
+ angle: 180
50
+ }
51
+ when: flip .flipped
52
+ }
53
+
54
+ transitions: Transition{
55
+ NumberAnimation{
56
+ target: rotation
57
+ properties: " angle"
58
+ duration: 1000
59
+ }
60
+ }
61
+ }
62
+
63
+ Row{
64
+ anchors .horizontalCenter : parent .horizontalCenter
65
+ anchors .bottom : parent .bottom
66
+ anchors .bottomMargin : 6
67
+
68
+ RadioButton{
69
+ id: rx
70
+ height: 24
71
+ text: qsTr (" X轴" )
72
+ checked: true
73
+ }
74
+
75
+ RadioButton{
76
+ id: ry
77
+ height: 24
78
+ text: qsTr (" Y轴" )
79
+ }
80
+
81
+ RadioButton{
82
+ id: rz
83
+ height: 24
84
+ text: qsTr (" Z轴" )
85
+ }
86
+ Button{
87
+ height: 24
88
+ text: qsTr (" 翻转" )
89
+ onClicked: flip .flipped = ! flip .flipped
90
+ }
91
+ }
92
+ }
Original file line number Diff line number Diff line change
1
+ <RCC>
2
+ <qresource prefix="/">
3
+ <file>main.qml</file>
4
+ <file>images/1.jpg</file>
5
+ <file>images/2.jpg</file>
6
+ </qresource>
7
+ </RCC>
Original file line number Diff line number Diff line change @@ -28,4 +28,5 @@ SUBDIRS += QmlTextEditScrollBar
28
28
SUBDIRS += QmlToggleButton
29
29
SUBDIRS += QmlCircularProgress
30
30
SUBDIRS += QmlFontList
31
+ SUBDIRS += QmlFlipImage
31
32
Original file line number Diff line number Diff line change @@ -122,3 +122,8 @@ QmlFontList: Qml获取字体列表
122
122
123
123
![ ] ( https://github.com/zhengtianzuo/QtQuickExamples/blob/master/QmlFontList/show.gif?raw=true )
124
124
125
+
126
+ QmlFlipImage: Qml翻转效果
127
+
128
+ ![ ] ( https://github.com/zhengtianzuo/QtQuickExamples/blob/master/QmlFlipImage/show.gif?raw=true )
129
+
You can’t perform that action at this time.
0 commit comments