Skip to content

Commit 8f5f6d7

Browse files
committed
Add QmlFlipImage
1 parent a0501ac commit 8f5f6d7

File tree

9 files changed

+140
-0
lines changed

9 files changed

+140
-0
lines changed

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

QmlFlipImage/images/1.jpg

147 KB
Loading

QmlFlipImage/images/2.jpg

43.7 KB
Loading

QmlFlipImage/main.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
}

QmlFlipImage/main.qml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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+
}

QmlFlipImage/qml.qrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
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>

QmlFlipImage/show.gif

1.4 MB
Loading

QtQuickExamples.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ SUBDIRS += QmlTextEditScrollBar
2828
SUBDIRS += QmlToggleButton
2929
SUBDIRS += QmlCircularProgress
3030
SUBDIRS += QmlFontList
31+
SUBDIRS += QmlFlipImage
3132

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,8 @@ QmlFontList: Qml获取字体列表
122122

123123
![](https://github.com/zhengtianzuo/QtQuickExamples/blob/master/QmlFontList/show.gif?raw=true)
124124

125+
126+
QmlFlipImage: Qml翻转效果
127+
128+
![](https://github.com/zhengtianzuo/QtQuickExamples/blob/master/QmlFlipImage/show.gif?raw=true)
129+

0 commit comments

Comments
 (0)