File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree 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+
19+ return app.exec ();
20+ }
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+ import QtGraphicalEffects 1.0
11+
12+ ApplicationWindow {
13+ visible: true
14+ width: 400
15+ height: 320
16+ title: qsTr (" Qml倒影" )
17+ color: " #AAAAAA"
18+
19+ Image {
20+ id: img
21+ width: 128
22+ height: 128
23+ anchors .top : parent .top
24+ anchors .topMargin : 16
25+ anchors .horizontalCenter : parent .horizontalCenter
26+ source: " qrc:/1.png"
27+
28+ ShaderEffect {
29+ height: parent .height
30+ width: parent .width
31+ anchors .top : parent .bottom
32+ anchors .left : parent .left
33+
34+ property variant source: img
35+ property size sourceSize: Qt .size (0.5 / img .width , 0.5 / img .height )
36+
37+ fragmentShader: "
38+ varying highp vec2 qt_TexCoord0;
39+ uniform lowp sampler2D source;
40+ uniform lowp vec2 sourceSize;
41+ uniform lowp float qt_Opacity;
42+ void main() {
43+ lowp vec2 tc = qt_TexCoord0 * vec2(1, -1) + vec2(0, 1);
44+ lowp vec4 col = 0.25 * (texture2D(source, tc + sourceSize)
45+ + texture2D(source, tc- sourceSize)
46+ + texture2D(source, tc + sourceSize * vec2(1, -1))
47+ + texture2D(source, tc + sourceSize * vec2(-1, 1))
48+ );
49+ gl_FragColor = col * qt_Opacity * (1.0 - qt_TexCoord0.y) * 0.5;
50+ }"
51+ }
52+ }
53+ }
Original file line number Diff line number Diff line change 1+ <RCC>
2+ <qresource prefix="/">
3+ <file>main.qml</file>
4+ <file>1.png</file>
5+ </qresource>
6+ </RCC>
Original file line number Diff line number Diff line change @@ -35,4 +35,5 @@ SUBDIRS += QmlWinExtras
3535SUBDIRS += QmlCalendar
3636SUBDIRS += QmlCanvasText
3737SUBDIRS += QmlKey
38- SUBDIRS += QmlLoader
38+ SUBDIRS += QmlLoader
39+ SUBDIRS += QmlInvertedImage
Original file line number Diff line number Diff line change @@ -162,3 +162,8 @@ QmlLoader: QmlLoader
162162
163163![ ] ( https://github.com/zhengtianzuo/QtQuickExamples/blob/master/QmlLoader/show.gif?raw=true )
164164
165+
166+ QmlInvertedImage: Qml倒影
167+
168+ ![ ] ( https://github.com/zhengtianzuo/QtQuickExamples/blob/master/QmlInvertedImage/show.jpg?raw=true )
169+
You can’t perform that action at this time.
0 commit comments