彩云之南的天是如此湛蓝,天上落下的水是如此清澈。

最近在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使用心得的更多相关文章

  1. qt qml中PropertyAnimation的几种使用方法

    qml文章 qt qml中PropertyAnimation的几种使用方法 动画应用场景有以下几种: 首先如果一个Rectangle.动画是要改变它的x和y值 1,Rectangle一旦被创建,就要移 ...

  2. 怎样在QML中使用multitouch

    在Qt QML中.它能够利用multitouch来做一些我们想做的事情.在今天的文章中.我们将介绍怎样使用multitouch来做一些我们想做的事. 事实上,在QML中利用多点触控是很easy的一件事 ...

  3. QT之在QML中使用C++类和对象

    QML其实是对ECMAScript的扩展,融合了Qt object系统,它是一种新的解释性语言,QML引擎虽然由Qt C++实现,但QML对象的运行环境说到底和C++对象的上下文环境是不通的,是平行的 ...

  4. qt quick中qml编程语言

    Qt QML 入门 — 使用C++定义QML类型 发表于 2013 年 3 月 11 日   注册C++类 注册可实例化的类型 注册不实例化的QML类型 附带属性 注册C++类 注册可实例化的类型 如 ...

  5. qml中打开本地html

    main.cpp QString tmploc = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); QDi ...

  6. qt qml 利用xmlhttprequest 调用有赞api

    最近朋友在有赞商城上面开了一个店铺,因为有实体店,一般卖商品后送货上门,但是打票时候老是人工用world文档人工复制黏贴订单打印小票, 所以就找我帮忙做一个软件专门打印小票的,就研究起来调用有赞第三方 ...

  7. qml 中 使用 shader

    使用绘制工具如Photoshop .Flash已经可以创建许多效果非常绚丽的图像.动画等. Qt/QML 的努力其实是在这些工具发展的后面, 因此很多效果在Qt中无法实现. 不得不佩服Qt小组的才智, ...

  8. 通过WebChannel/WebSockets与QML中的HTML交互

    来源:通过WebChannel/WebSockets与QML中的HTML交互 GitHub:八至 作者:狐狸家的鱼 本文链接:QML与HTML交互 在查询QML与HTML之间通信交互时资料很少,这篇文 ...

  9. 在Qt Quick中一个简单Hello World加载过程

    Qt5基本类图: QQmlEngine    QQmlEngine类提供了一个QML引擎,用于管理由QML文档定义的对象层次架构,QML提供了一个默认的QML上下文(根上下文,获取函数QQmlEngi ...

随机推荐

  1. 运行级别 runlevel

    linux默认有7个等级,从0到6 0 关机 1 单用户模式,系统出现问题是可使用该模式进入系统.例如完了root密码,就可以使用1进入系统修改root密码 2 多用户模式,没有网络连接 3 完全多用 ...

  2. leetcode解题报告(16):Move Zeroes

    描述 Given an array nums, write a function to move all 0's to the end of it while maintaining the rela ...

  3. P4514 上帝造题的七分钟——二维树状数组

    P4514 上帝造题的七分钟 求的是矩阵里所有数的和: 维护四个树状数组: #include<cstdio> #include<cstring> #include<alg ...

  4. NOIP1998提高组 题解报告

    T1 进制位 题目大意:自己看吧 首先让我们来看两个引理: 如果有解,则进制一定为\(n - 1\) 如果有解,则字母一定表示\(0\) 至 \(n - 1\) 的数 证明如下: 因为有 \(n - ...

  5. ICEM rpl文件简要讲解【转载】

    转载自:http://blog.sina.com.cn/s/blog_90affd9801016xti.html 很多人问ICEM的rpl怎样录制的问题,为什么CFX调用时老是报错,这里开个帖子简单讲 ...

  6. 服务端 CORS 解决跨域

    当协议.域名.端口中任一个不同时产生跨域 CORS 跨域资源共享(Cross-origin resource sharing) 参考资料https://developer.mozilla.org/zh ...

  7. TynSerial序列(还原)TClientDataSet

    TynSerial序列(还原)TClientDataSet 可以一次性序列(还原)多个TClientDataSet. 1)TClientDataSet查询数据 procedure TForm1.Qry ...

  8. C++ .h 与 .hpp 的区别

    原文地址:http://blog.csdn.net/f_zyj/article/details/51735416 .hpp,本质就是将.cpp的实现代码混入.h头文件当中,定义与实现都包含在同一文件, ...

  9. madam、Linux LVM的使用

    .RaidRAID(独立冗余磁盘阵列)概念:RAID技术通过把多个硬盘设备组合成一个容量更大.安全性更好的磁盘阵列,并把数据切割成多个区段后分别存放在各个不同的物理硬盘设备上,然后利用分散读写技术来提 ...

  10. 阿里巴巴高可用技术专家襄玲:压测环境的设计和搭建 PTS - 襄玲 云栖社区 今天

    阿里巴巴高可用技术专家襄玲:压测环境的设计和搭建 PTS - 襄玲 云栖社区 今天