QtQuick堆栈窗口
2016-06-08 16:39
519 查看
这个好像在之前的版本就有了,QtQuick的堆栈窗口 depth表示当前堆栈中的窗口数量,每一个窗口可以是一个自定义组件 也可以是一个url。push添加新窗口,pop返回上层。在AppXXXWindow下,顶部导航会遮挡堆栈窗口。因此要写逻辑隐藏,他有一个initialItem属性,是默认的第一个堆栈窗口,也就是顶层窗口。每一个push的窗口有自己的内存,不会因为push相同的id而造成数据混乱
ApplicationWindow { id:root visible: true; height: 480; width: 320; property real pixelDensity: 4.46 property real multiplierH: root.height/480 //default multiplier, but can be changed by user property real multiplierW: root.width/320 //default multiplier, but can be changed by user function dpH(numbers) { return Math.round(numbers*((pixelDensity*25.4)/160)*multiplierH); } function dpW(numbers) { return Math.round(numbers*((pixelDensity*25.4)/160)*multiplierW); } property color accentcol:"red" property color backgroundcol:"white" property color foregroundcol:"#000000" property color primarycol:"blue" Material.accent:accentcol Material.background:backgroundcol Material.foreground:foregroundcol Material.primary: primarycol header: ToolBar{ id:hd; visible: stackView.depth>1?false:true height: stackView.depth>1?0:dpH(72) Text{ text:"hello"; anchors.centerIn: parent color: "white"; } } SwipeView{ id:sw; anchors.fill: parent; currentIndex: footertabBar.currentIndex; Page1{ } Item{ StackView { property int cur: 0; id: stackView; anchors.fill: parent initialItem: Pane { id: pane padding: 10 ColumnLayout{ Label{ text:stackView.cur ; } Button{ text:"push"; onClicked: { stackView.push(subpage) } } } } } } } Component{ id:subpage; Item{ ToolBar{ id:bar; width: root.width; anchors.top: root.top height: dpH(72) Row{ id:row; anchors.fill: parent Text{ height: parent.height; text:"<----"; verticalAlignment: Text.AlignVCenter anchors.verticalCenter : parent.verticalCenter color: "white"; MouseArea{ anchors.fill: parent; onClicked: { stackView.depth; stackView.pop(); } } } Text{ text:"当前序号:"+stackView.depth; anchors.centerIn: parent color: "white"; } Text{ height: parent.height; text:"---->"; verticalAlignment: Text.AlignVCenter anchors.verticalCenter : parent.verticalCenter anchors.right: parent.right color: "white"; MouseArea{ anchors.fill: parent; onClicked: { stackView.push(subpage) } } } } } ColumnLayout{ anchors.top:bar.bottom width: parent.width height: parent.height Rectangle{ anchors.fill: parent; color:Qt.rgba( Math.random(255), Math.random(255), Math.random(255), Math.random(255)); } } } } footer: TabBar { id: footertabBar currentIndex: sw.currentIndex TabButton { text: qsTr("footer Tab1"); } TabButton { text: qsTr("footer Tab2") } TabButton { text: qsTr("footer Tab3") } } }
相关文章推荐
- Java API中的阻塞队列(BlockingQueue)
- iOS的UI Test
- quick真机调试注意事项
- java基础教程--StringBuilder
- @page指令 validateRequest的作用
- Failed to build DependencyGraph
- UIView常用
- iOS开发技巧(系列十八:扩展UIColor,支持十六进制颜色设置)
- 62. Unique Paths
- easyui展示时间遇到的问题
- 通过modbus协议实现arduino与电能表串口通信(仅03功能)
- iOS监听UITextView、UITextField键盘删除键
- iOS 全局修改UINavigation 后退按钮
- 关于UIView 的autoresizingMask属性,即UIViewAutoresizing
- MySQL 自学笔记之:数据库查询 DQL(Data Query Lanuage)汇总函数
- MySQL 自学笔记之:数据库查询 DQL(Data Query Lanuage)数据分类(where 子语句)
- EasyUI 第一个demo
- Errors running builder 'Integrated External Tool Builder' on project '项目名'
- 微信支付 总提示get_brand_wcpay_request:fail 也不跳转支付页面 的解决方案
- GY-30数字光强传感器通过I²C接入Arduino