qt qml中的Tabview使用心得
彩云之南的天是如此湛蓝,天上落下的水是如此清澈。
最近在qt5.5下使用TabView,如下。
1) currentIndex变量很好用,其对应当前被显示的tab,其值变化时还会触发onCurrentIndexChanged函数。
2)加载如下的qml文件时,例如用一个QquickView显示,tab1和tab2会被创建,一直到整个View被关闭时,才被销毁。
对于tab内定义的rectangle,当tab第一次被显示时,其才会被构建,直到View被关闭时,才被销毁。
下面这段代码的输出顺序:
tab2 has been finished --- >tab1 has been finished --- >tabview has been finished --- > // 先建立tab,空的tab
Rectangle of tab1 has been finished ---> // 第一次显示时,指定了currentIndex:0,tab1内的控件先被生成
-->点击tab2-->Rectangle of tab2 has been finished--->当一个tab被第一次显示时,其内部的控件才被构建
--->onCurrentIndexChanged!!currentindex=1!!!---->被构建完了之后才调用的currentIndexchange槽函数
--->点击tab1-->onCurrentIndexChanged!!currentindex=0!!!
--->点击tab2-->onCurrentIndexChanged!!currentindex=1!!!
--->CloseView--> Rectangle of tab2 has been destructed --> Rectangle of tab1 has been destructed -->tab2 has been destructed!!-->tab1 has been destructed!!-->tabview has been destructed!! //先销毁tab内的widege,然后销毁tab,最后销毁tabview
TabView
{
id: tabview
Component.onCompleted:{console.log("tabview has been finished!");}
Component.onDestruction: console.log("tabview has been destructed!!")
property var array:[] //define array
property bool flag: false
x: 0
y: 0
width: 800
height: 900
currentIndex: 0//One TabView can contains many tabs, currentIndex = 0 means making the first tab be visiable and others unvisiable.
onCurrentIndexChanged: //when you choose different tabs by clicking, this slot function is called automatically.
{ //console.log("onCurrentIndexChanged!!!!!")
if(currentIndex==0)
{
console.log("onCurrentIndexChanged!!currentindex=0!!!")
}
else if(currentIndex==1)
{
console.log("onCurrentIndexChanged!!currentindex=1!!!")
}
}
Tab
{
id:taba
title: "tab1"
Component.onCompleted:
{
console.log("tab1 has been finished!");
}
Component.onDestruction: console.log("tab1 has been destructed!!")
Rectangle
{
id: rect1
Component.onCompleted:{console.log("Rectangle of tab1 has been finished!");}
Component.onDestruction: console.log("Rectangle of tab1 has been destructed!!")
color:"steelblue"
}
}
Tab
{
id:tabb title: "tab2"
Component.onCompleted:{console.log("tab2 has been finished!");}
Component.onDestruction: console.log("tab2 has been destructed!!")
Rectangle
{
id: rect2
Component.onCompleted:{console.log("Rectangle of tab2 has been finished!");}
Component.onDestruction: console.log("Rectangle of tab2 has been destructed!!")
color:"steelblue"
}
}
}
qt qml中的Tabview使用心得的更多相关文章
- qt qml中PropertyAnimation的几种使用方法
qml文章 qt qml中PropertyAnimation的几种使用方法 动画应用场景有以下几种: 首先如果一个Rectangle.动画是要改变它的x和y值 1,Rectangle一旦被创建,就要移 ...
- 怎样在QML中使用multitouch
在Qt QML中.它能够利用multitouch来做一些我们想做的事情.在今天的文章中.我们将介绍怎样使用multitouch来做一些我们想做的事. 事实上,在QML中利用多点触控是很easy的一件事 ...
- QT之在QML中使用C++类和对象
QML其实是对ECMAScript的扩展,融合了Qt object系统,它是一种新的解释性语言,QML引擎虽然由Qt C++实现,但QML对象的运行环境说到底和C++对象的上下文环境是不通的,是平行的 ...
- qt quick中qml编程语言
Qt QML 入门 — 使用C++定义QML类型 发表于 2013 年 3 月 11 日 注册C++类 注册可实例化的类型 注册不实例化的QML类型 附带属性 注册C++类 注册可实例化的类型 如 ...
- qml中打开本地html
main.cpp QString tmploc = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); QDi ...
- qt qml 利用xmlhttprequest 调用有赞api
最近朋友在有赞商城上面开了一个店铺,因为有实体店,一般卖商品后送货上门,但是打票时候老是人工用world文档人工复制黏贴订单打印小票, 所以就找我帮忙做一个软件专门打印小票的,就研究起来调用有赞第三方 ...
- qml 中 使用 shader
使用绘制工具如Photoshop .Flash已经可以创建许多效果非常绚丽的图像.动画等. Qt/QML 的努力其实是在这些工具发展的后面, 因此很多效果在Qt中无法实现. 不得不佩服Qt小组的才智, ...
- 通过WebChannel/WebSockets与QML中的HTML交互
来源:通过WebChannel/WebSockets与QML中的HTML交互 GitHub:八至 作者:狐狸家的鱼 本文链接:QML与HTML交互 在查询QML与HTML之间通信交互时资料很少,这篇文 ...
- 在Qt Quick中一个简单Hello World加载过程
Qt5基本类图: QQmlEngine QQmlEngine类提供了一个QML引擎,用于管理由QML文档定义的对象层次架构,QML提供了一个默认的QML上下文(根上下文,获取函数QQmlEngi ...
随机推荐
- 如何自定义 GNOME 3 桌面?
作者: Magesh Maruthamuthu 译者: LCTT 郑 | 2019-08-22 00:02 评论: 2 收藏: 1 我们收到很多来自用户的电子邮件,要我们写一篇关于 GNOME 3 ...
- Atcoder Rating System
来翻译一下官方文档,但是建议看英文原文,本文可能会出现一些错误,只是为了方便自己查阅用的. 对于你的每一场rated比赛,会有一个Performance值\(X_i\),你的rating是\(X_i- ...
- Invalid Component definition:header
主要是header不是字符串,而是变量
- AWS 配置IPv6
- 性能监控 | MAT分析内存泄漏
使用MAT分析内存泄漏(二)八周年重印版 - 知乎 .u-safeAreaInset-top { height: constant(safe-area-inset-top) !important; h ...
- spring (反射+代理+DI+AOP)
spring https://baijiahao.baidu.com/s?id=1620606848227713760&wfr=spider&for=pc 反射 https://bl ...
- colorMatrix色彩旋转设置
package com.loaderman.customviewdemo; import android.app.Activity; import android.graphics.Bitmap; i ...
- Pattern 和 Matcher
作用:应用这个 Pattern 和 Matcher 可以完成字符串获取功能 使用: // 获取模式器对象 Pattern p = Pattern.compile("a*b") ; ...
- 33Flutter仿京东商城项目 登录 注册相关页面布局
加群452892873 下载对应33课文件,运行方法,建好项目,直接替换lib目录 以下列出的是本课涉及的文件. User.dart import 'package:flutter/material. ...
- 阶段5 3.微服务项目【学成在线】_day16 Spring Security Oauth2_19-认证接口开发-接口开发-controller
补充controller方法 判断是否有值传过来. 私有方法存储cookie httpOnly设置为false的话 浏览器就拿到这个cookie 拿到Response cookie在配置文件内的配置 ...