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 ...
随机推荐
- Python3循环
Python中while语句的一般形式: while 判断条件: 语句 同样需要注意冒号和缩进,另外在Python中没有do…while循环 下面的实例计算1到100总和 ##calc.py n = ...
- python常用函数1
map()函数 map()是python 内置 的高届函数 ,接收一个函数 f 和一个list,并通过把函数 f 依次作用在list的每个元素上,得到一个新的 list 并返回. 比如,对于l ...
- nodeJs 初学案例摘要
在学习nodeJs的时候,照着文档做的,但是到最后的上传文件显示图片总是报错, 所用的fs.renameSync出错:Error: EXDEV, cross-device link not permi ...
- jenkins之docker安装(jenkins/jenkins:lts)
建议使用此镜像安装,不要使用官网推荐的jenkinsci/blueocean镜像,使用它构建node程序会出现问题. 1.宿主服务器jenkins_home目录权限 为了方便安装插件,升级,迁移,因此 ...
- Dubbo的SPI是个什么鬼
原文:https://mp.weixin.qq.com/s/bQc_tASkfsojlcd897kLtA # spi 是啥? spi,简单来说,就是 service provider interfac ...
- 【spring源码分析】IOC容器初始化——查漏补缺(五)
前言:我们知道在Spring中经常使用配置文件的形式对进行属性的赋值,那配置文件的值是怎么赋值到属性上的呢,本文将对其进行分析. 首先了解一个类:PropertySourcesPlaceholderC ...
- ASP.NET Routing Debugger
How do you debug MVC 4 API routes? 解答1 RouteDebugger is good for figuring out which routes will/will ...
- C++ .h 与 .hpp 的区别
原文地址:http://blog.csdn.net/f_zyj/article/details/51735416 .hpp,本质就是将.cpp的实现代码混入.h头文件当中,定义与实现都包含在同一文件, ...
- PowerDesigner 使用小结
这里总结一篇关于数据建模工具 PowerDesigner 的使用小技巧,下面列出的两个应用场景要在网上现找解决方案的话还真不一定好找,所以选择将这两个棘手的问题先记下来. 1. PDM 中表间关系出现 ...
- P5663 加工零件
P5663 加工零件 题解 暴力搜索 搜索显然会TLE #include<iostream> #include<cstdio> #include<cstdlib> ...