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

最近在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. Set集合类

    1.1  Set.add方法——向Set集合添加对象 public static void main(String[] args) {  Set set = new HashSet();      / ...

  2. Springboot @ConditionalOnProperty注解

    最近看了一段代码其中用到了@ConditionalOnProperty注解,直接没有了解过这个注解,今天看到了顺便了解一下 具体代码如下 @Configuration public class Web ...

  3. 在win10环境下IED配置spark项目

    eclipse在对spark的支持上并不友好,所以需要新下载并安装IntelliJ IDEA 2019.1.我下载安装的是专业版的,直接在网上搜索了破解码进行破解. 1. 配置java和scala I ...

  4. harukaの赛前日常

    REMEMBER US. haruka是可爱的孩子. 如题,此博客用来记录我停课后的日常. Dear Diary 10.8 上午考试. T1,直接枚举每一个点最后一次被修改的情况.(100pts) T ...

  5. PL/SQL配置和连接远端数据库

    1. 安装与配置 (1) 安装 因为是免安装的绿色版,所以解压到目录就可以了,保证目录中没有空格.下划线和中文字符. 还有一点,PL/SQL需要和Oracle的版本一致,都是32位或者都是64位,否则 ...

  6. NSCTF 2017-pwn2

    目录 程序基本信息 程序漏洞 整体思路 exp脚本 发现的问题 内容参考 程序基本信息 32位动态链接程序,开启了数据段不可执行以及栈溢出保护 程序漏洞 在函数中sub_80487fa中有一个格式化字 ...

  7. javascript 的垃圾回收机制讲一下

    定义:指一块被分配的内存既不能使用,又不能回收,直到浏览器进程结束. 像 C 这样的编程语言,具有低级内存管理原语,如 malloc()和 free().开发人员使用这些原语显式地对操作系统的内存进行 ...

  8. CORTEX-M3中断的现场保护问题

    在<Cortex-M3 Devices Generic User Guide.pdf>中介绍了异常入栈和出栈的情况,详见2.3 Exception model.Cortex-M3内核的寄存 ...

  9. vue-cli项目中使用全局过滤器及传参(日期格式化)

    // 过滤日期格式,传入时间戳,根据参数返回不同格式 const formatTimer = function(val, hours) { if (val) { ); var y = dateTime ...

  10. C# 将文本写入到文件

    将字符串数组写入到文件,每个元素为一行 string[] lines = { "First line", "Second line", "Third ...