在QML应用中是用DefaultSheet及ComposerSheet
来源:互联网 发布:记录轨迹软件 编辑:程序博客网 时间:2024/04/28 11:18
在应用中有时我们希望在不中断应用界面导航的前提下,我们希望插入一个展示内容的窗口。我们可以是用DefaultSheet及ComposerSheet来显示我们所需要的内容。其实在以前我们的Dialog教程中,有类似的功能尽管展示有一点不同。
我们来做一个练习:
import QtQuick 2.0import Ubuntu.Components 1.1import Ubuntu.Components.Popups 0.1/*! \brief MainView with a Label and Button elements.*/MainView { // objectName for functional testing purposes (autopilot-qt5) objectName: "mainView" // Note! applicationName needs to match the "name" field of the click manifest applicationName: "sheet.liu-xiao-guo" /* This property enables the application to change orientation when the device is rotated. The default is false. */ //automaticOrientation: true // Removes the old toolbar and enables new features of the new header. useDeprecatedToolbar: false width: units.gu(60) height: units.gu(85) Page { title: i18n.tr("sheet") Component { id: defaultSheet DefaultSheet { id: sheet title: i18n.tr("Default sheet Title")// doneButton: true Label { anchors.fill: parent wrapMode: Text.WordWrap text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " + "Integer et ante at erat malesuada accumsan in eget mauris. " + "Nunc ultrices tristique laoreet. In non tristique lorem. " + "Donec in libero ut libero pretium lacinia. Proin dictum faucibus viverra. " } } } Component { id: composerSheet ComposerSheet { id: sheet title: i18n.tr("Composer sheet") Label { anchors.fill: parent wrapMode: Text.WordWrap text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " + "Integer et ante at erat malesuada accumsan in eget mauris. " + "Nunc ultrices tristique laoreet. In non tristique lorem. " + "Donec in libero ut libero pretium lacinia. Proin dictum faucibus viverra. " } onCancelClicked: PopupUtils.close(sheet) onConfirmClicked: PopupUtils.close(sheet) } } Row { anchors.centerIn: parent spacing: units.gu(2) Button { text: "Default sheet" onClicked: { PopupUtils.open(defaultSheet, null) } } Button { text: "Composer Sheet" onClicked: { PopupUtils.open(composerSheet, null) } } } }}
对于DefaultSheet来说,我们可以看见一个“Close”按钮,当然,我们也可以设置它的属性“doneButton”为真,这样就会有“Done”的按钮。当然,这两个按钮不可以同时出现:
对于ComposerSheet来说,它有两个按钮“Cancel”及“Confirm”。这样我们就可以利用这两个按钮来确认或放弃我们在Sheet中的修改(如果有edit及选项的情况)。
结合我们先前的Dialog来说,展示的有些类似的地方。但是Dialog显示的没有这么宽,并且背景的颜色显示的黑色的。
在我们先前的教程“从零开始创建一个Ubuntu应用--一个小的RSS阅读器”。在第一部分的练习中,我们可以甚至可以利用DefaultSheet来展示我们的RSS内容而不需要创建一个新的Component。
整个项目的源码是:https://github.com/liu-xiao-guo/sheet
0 0
- 在QML应用中是用DefaultSheet及ComposerSheet
- 如何在QML应用中得到一个Item的所有属性,信号及方法
- 如何在QML应用中读写文件
- 正确地在QML应用中使用fontsize
- 如何在QML应用中启动Scope
- QQuickImageProvider在QML设计中的应用
- 在QML应用中显示image tag
- 浅析AbstractButton在QML中的应用
- 正确地在QML应用中使用fontsize
- QML笔记整理——在Qt/C++应用中使用QML
- 在QML应用中使用VisualItemModel让QML Item成为model来显示数据
- 在Ubuntu OS上怎么本地化一个QML应用
- 如何在Ubuntu QML应用中使用Push Notification
- 怎么在Ubuntu QML应用中侦测到Swipe手势
- 如何在QML应用中使用Javascript解析JSON
- 如何在QML应用中使用Javascript来解析XML
- 如何在Ubuntu QML应用中播放音乐
- 如何在Ubuntu QML应用中播放视频
- DirectX中文手册
- C# TextBox中只允许输入数字的方法
- 编程工具总结
- IOS开发UIView之动画效果的实现方法(合集)
- dm8148 jpeg合成问题
- 在QML应用中是用DefaultSheet及ComposerSheet
- jquery mobile框架,用超链接定位到其他页面,会出现不能跳转或者跳转后页面js代码不能执行现象
- 常用RGB颜色表 色值
- 低容量STM8 Modbus协议移植与裁剪
- android动态布局方法总结
- Red Hat Install
- python类库26[读写Excel]
- Android国内怎么上google和Gemail?(外游加速器分享)
- IntelliJ IDEA快捷键(常用)