File tree Expand file tree Collapse file tree 9 files changed +195
-0
lines changed Expand file tree Collapse file tree 9 files changed +195
-0
lines changed Original file line number Diff line number Diff line change
1
+ import QtQuick 2.7
2
+ import QtQuick.Window 2.0
3
+ import QtQuick.Controls 2.0
4
+
5
+ Window {
6
+ width: 400
7
+ height: 300
8
+ visible: true
9
+ flags: Qt .Window | Qt .WindowStaysOnTopHint
10
+
11
+ Text {
12
+ anchors .top : parent .top
13
+ anchors .topMargin : 4
14
+ anchors .horizontalCenter : parent .horizontalCenter
15
+ text: qsTr (" 主页一" )
16
+ }
17
+
18
+ Button{
19
+ height: 32
20
+ width: 60
21
+ anchors .centerIn : parent
22
+ text: qsTr (" 下一页" )
23
+ onClicked: changePage ();
24
+ }
25
+
26
+ Button{
27
+ height: 32
28
+ width: 32
29
+ text: " X"
30
+ anchors .right : parent .right
31
+ anchors .rightMargin : 4
32
+ anchors .top : parent .top
33
+ anchors .topMargin : 4
34
+ onClicked: {
35
+ Qt .quit ()
36
+ }
37
+ }
38
+
39
+ Loader{
40
+ id: pageLoader
41
+ }
42
+
43
+ function changePage (){
44
+ pageLoader .source = " Page2.qml"
45
+ close ();
46
+ }
47
+ }
Original file line number Diff line number Diff line change
1
+ import QtQuick 2.7
2
+ import QtQuick.Window 2.0
3
+ import QtQuick.Controls 2.0
4
+
5
+ Window {
6
+ width: 400
7
+ height: 300
8
+ visible: true
9
+ flags: Qt .Window | Qt .WindowStaysOnTopHint
10
+
11
+ Text {
12
+ anchors .top : parent .top
13
+ anchors .topMargin : 4
14
+ anchors .horizontalCenter : parent .horizontalCenter
15
+ text: qsTr (" 主页二" )
16
+ }
17
+
18
+ Button{
19
+ height: 32
20
+ width: 60
21
+ anchors .centerIn : parent
22
+ text: qsTr (" 下一页" )
23
+ onClicked: changePage ();
24
+ }
25
+
26
+ Button{
27
+ height: 32
28
+ width: 32
29
+ text: " X"
30
+ anchors .right : parent .right
31
+ anchors .rightMargin : 4
32
+ anchors .top : parent .top
33
+ anchors .topMargin : 4
34
+ onClicked: {
35
+ Qt .quit ()
36
+ }
37
+ }
38
+
39
+ Loader{
40
+ id: pageLoader
41
+ }
42
+
43
+ function changePage (){
44
+ pageLoader .source = " main.qml"
45
+ close ();
46
+ }
47
+ }
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.Window 2.0
10
+ import QtQuick.Controls 2.0
11
+
12
+ Window {
13
+ width: 400
14
+ height: 300
15
+ visible: true
16
+ flags: Qt .Window | Qt .WindowStaysOnTopHint
17
+ title: qsTr (" QmlLoader" )
18
+
19
+ Text {
20
+ anchors .top : parent .top
21
+ anchors .topMargin : 4
22
+ anchors .horizontalCenter : parent .horizontalCenter
23
+ text: qsTr (" 主页面" )
24
+ }
25
+
26
+ Button{
27
+ height: 32
28
+ width: 60
29
+ anchors .centerIn : parent
30
+ text: qsTr (" 下一页" )
31
+ onClicked: changePage ();
32
+ }
33
+
34
+ Button{
35
+ height: 32
36
+ width: 32
37
+ text: " X"
38
+ anchors .right : parent .right
39
+ anchors .rightMargin : 4
40
+ anchors .top : parent .top
41
+ anchors .topMargin : 4
42
+ onClicked: {
43
+ Qt .quit ()
44
+ }
45
+ }
46
+
47
+ Loader{
48
+ id: pageLoader
49
+ }
50
+
51
+ function changePage (){
52
+ pageLoader .source = " Page1.qml"
53
+ close ();
54
+ }
55
+ }
Original file line number Diff line number Diff line change
1
+ <RCC>
2
+ <qresource prefix="/">
3
+ <file>main.qml</file>
4
+ <file>Page1.qml</file>
5
+ <file>Page2.qml</file>
6
+ </qresource>
7
+ </RCC>
Original file line number Diff line number Diff line change @@ -35,3 +35,4 @@ SUBDIRS += QmlWinExtras
35
35
SUBDIRS += QmlCalendar
36
36
SUBDIRS += QmlCanvasText
37
37
SUBDIRS += QmlKey
38
+ SUBDIRS += QmlLoader
Original file line number Diff line number Diff line change @@ -157,3 +157,8 @@ QmlKey: Qml全局按键
157
157
158
158
![ ] ( https://github.com/zhengtianzuo/QtQuickExamples/blob/master/QmlKey/show.gif?raw=true )
159
159
160
+
161
+ QmlLoader: QmlLoader
162
+
163
+ ![ ] ( https://github.com/zhengtianzuo/QtQuickExamples/blob/master/QmlLoader/show.gif?raw=true )
164
+
You can’t perform that action at this time.
0 commit comments