File tree 10 files changed +251
-1
lines changed
10 files changed +251
-1
lines changed Original file line number Diff line number Diff line change
1
+ /*!
2
+ *@file Page1.qml
3
+ *@brief Page1
4
+ *@version 1.0
5
+ *@section LICENSE Copyright (C) 2003-2103 CamelSoft Corporation
6
+ *@author zhengtianzuo
7
+ */
8
+ import QtQuick 2.8
9
+ import QtQuick.Controls 2.1
10
+
11
+ Page {
12
+ id: frmWindow
13
+ title: qsTr (" 设置" )
14
+ visible: true
15
+
16
+ property StackView stack: null
17
+
18
+ Button {
19
+ height: 32
20
+ width: 120
21
+ text: " <-"
22
+ anchors .left : parent .left
23
+ anchors .top : parent .top
24
+ onClicked: stack .pop ()
25
+ }
26
+
27
+ Label{
28
+ id: label
29
+ text: qsTr (" 设置" )
30
+ height: 80
31
+ width: 240
32
+ anchors .centerIn : parent
33
+ font .pixelSize : 20
34
+ }
35
+
36
+ Button {
37
+ height: 32
38
+ width: 120
39
+ text: qsTr (" 个人设置" )
40
+ anchors .right : parent .right
41
+ anchors .bottom : parent .bottom
42
+ onClicked: {
43
+ page2 .visible = true ;
44
+ page2 .stack = stack;
45
+ stack .push (page2);
46
+ }
47
+ }
48
+
49
+ Page2 {
50
+ id: page2
51
+ visible: false
52
+ }
53
+ }
Original file line number Diff line number Diff line change
1
+ /*!
2
+ *@file Page2.qml
3
+ *@brief Page2
4
+ *@version 1.0
5
+ *@section LICENSE Copyright (C) 2003-2103 CamelSoft Corporation
6
+ *@author zhengtianzuo
7
+ */
8
+ import QtQuick 2.8
9
+ import QtQuick.Controls 2.1
10
+
11
+ Page {
12
+ id: frmWindow
13
+ title: qsTr (" 个人设置" )
14
+ visible: true
15
+
16
+ property StackView stack: null
17
+
18
+ Button {
19
+ height: 32
20
+ width: 120
21
+ text: " <-"
22
+ anchors .left : parent .left
23
+ anchors .top : parent .top
24
+ onClicked: stack .pop ()
25
+ }
26
+
27
+ Label{
28
+ id: label
29
+ text: qsTr (" 个人设置" )
30
+ height: 80
31
+ width: 240
32
+ anchors .centerIn : parent
33
+ font .pixelSize : 20
34
+ }
35
+
36
+ Button {
37
+ height: 32
38
+ width: 120
39
+ text: qsTr (" 帐号" )
40
+ anchors .right : parent .right
41
+ anchors .bottom : parent .bottom
42
+ onClicked: {
43
+ page3 .visible = true ;
44
+ page3 .stack = stack;
45
+ stack .push (page3);
46
+ }
47
+ }
48
+
49
+ Page3 {
50
+ id: page3
51
+ visible: false
52
+ stack: stack
53
+ }
54
+ }
Original file line number Diff line number Diff line change
1
+ /*!
2
+ *@file Page3.qml
3
+ *@brief Page3
4
+ *@version 1.0
5
+ *@section LICENSE Copyright (C) 2003-2103 CamelSoft Corporation
6
+ *@author zhengtianzuo
7
+ */
8
+ import QtQuick 2.8
9
+ import QtQuick.Controls 2.1
10
+
11
+ Page {
12
+ id: frmWindow
13
+ title: qsTr (" 帐号" )
14
+ visible: true
15
+
16
+ property StackView stack: null
17
+
18
+ Button {
19
+ height: 32
20
+ width: 120
21
+ text: " <-"
22
+ anchors .left : parent .left
23
+ anchors .top : parent .top
24
+ onClicked: stack .pop ()
25
+ }
26
+
27
+ Label{
28
+ id: label
29
+ text: qsTr (" 帐号" )
30
+ height: 80
31
+ width: 240
32
+ anchors .centerIn : parent
33
+ font .pixelSize : 20
34
+ }
35
+
36
+ Label{
37
+ anchors .top : label .bottom
38
+ anchors .horizontalCenter : parent .horizontalCenter
39
+ text: qsTr (" 帐号信息" )
40
+ height: 80
41
+ width: 240
42
+ font .pixelSize : 20
43
+ }
44
+ }
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.8
9
+ import QtQuick.Controls 2.1
10
+
11
+ ApplicationWindow {
12
+ id: frmWindow
13
+ title: qsTr (" Qml堆栈窗体" )
14
+ width: 400
15
+ height: 300
16
+ visible: true
17
+
18
+ StackView {
19
+ id: stack
20
+ initialItem: mainView
21
+ anchors .fill : parent
22
+ }
23
+
24
+ Page {
25
+ id: mainView
26
+
27
+ Label{
28
+ text: qsTr (" 主页" )
29
+ height: 80
30
+ width: 240
31
+ anchors .centerIn : parent
32
+ font .pixelSize : 20
33
+ }
34
+ Button {
35
+ height: 32
36
+ width: 120
37
+ text: qsTr (" 设置" )
38
+ anchors .right : parent .right
39
+ anchors .bottom : parent .bottom
40
+ onClicked: {
41
+ page1 .visible = true ;
42
+ page1 .stack = stack;
43
+ stack .push (page1)
44
+ }
45
+ }
46
+ }
47
+
48
+ Page1 {
49
+ id: page1
50
+ visible: false
51
+ }
52
+ }
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
+ <file>Page3.qml</file>
7
+ </qresource>
8
+ </RCC>
Original file line number Diff line number Diff line change @@ -19,4 +19,5 @@ SUBDIRS += QmlCircular
19
19
SUBDIRS += QmlRotationAnimation
20
20
SUBDIRS += QmlShowSideWindow
21
21
SUBDIRS += QmlSign
22
- SUBDIRS += QmlSlidingMenu
22
+ SUBDIRS += QmlSlidingMenu
23
+ SUBDIRS += QmlStackView
Original file line number Diff line number Diff line change @@ -80,3 +80,8 @@ QmlSlidingMenu: Qml侧边滑动菜单
80
80
81
81
![ ] ( https://github.com/zhengtianzuo/QtQuickExamples/blob/master/QmlSlidingMenu/show.gif?raw=true )
82
82
83
+
84
+ QmlStackView: Qml堆栈窗体
85
+
86
+ ![ ] ( https://github.com/zhengtianzuo/QtQuickExamples/blob/master/QmlStackView/show.gif?raw=true )
87
+
You can’t perform that action at this time.
0 commit comments