QML 从无到有 (基础)
2024-10-19 23:26:38
小公司,没办法,什么都得自己亲自来。
服务端是MVC,现在需要可PC客户端和移动APP。
考虑到网页应用有很多界面框架,可以做出很漂亮的界面来,就尝试着使用nwjs来实现,可是在使用了2天的nwjs后,鄙人能力有限,而且文档资料有限,被迫放弃,转而使用Qt来开发,想着反正都不熟悉,就用QML来开发,好在熟悉起来很快,文档也很多,中间很多坑,下面就记录这些过程。
1.子控件可以直接调用父控件的方法
2.ScrollView默认的滚动条太丑,可以通过style: ScrollViewStyle自定义。
ScrollView {
id:scroll
width: parent.width
height: parent.height - get_y(23) Column
{
id:machineList
} style: ScrollViewStyle {
//transientScrollBars: true
handle: Item {
implicitWidth: get_x(14)
implicitHeight: 0
Rectangle {
color: "#dddddd"
anchors.fill: parent
anchors.topMargin: get_y(4)
anchors.leftMargin: get_x(2)
anchors.rightMargin: get_x(2)
anchors.bottomMargin: get_y(4)
}
}
scrollBarBackground: Rectangle {
implicitWidth: get_x(14)
implicitHeight: 0
color: "#f0f0f0"
}
decrementControl: Rectangle {
implicitWidth: 0
implicitHeight: 0
}
incrementControl: Rectangle {
implicitWidth: 0
implicitHeight: 0
}
}
}
内容都是listitem,都放在Column中
3.动态添加自定义控件
property Component component: null;
if(main.component == null){
main.component = Qt.createComponent("MachineItem.qml");
}
var item;
if(main.component.status == Component.Ready) {
item = main.component.createObject(machineList, { "x":0, "y" : 0});
}
4.删除动态添加的控件
var list = machineList.children; for(var i = list.length; i > 0 ; i--) {
list[i-1].visible = false;
list[i-1].destroy();
}
由于是刷新machineList,先删除在重新添加,在安卓平台会有闪烁,设置list[i-1].visible = false;就可以消除。
最新文章
- ubuntu下安装oracle
- dedecms如何自定义专题模板
- 【转载】C语言中的undefined behavior/unspecified behavior - 序
- nginx 414 Request-URI Too Large
- sublime text 2使用经验
- [Webpack 2] Optimize React size and performance with Webpack production plugins
- C# Login方法
- CAEmitterLayer
- 【子非鱼】插入排序过程呈现之java内置GUI表示
- Linux设置PHP环境变量
- jdbc、jpa、spring data jpa、hibernate、mybatis之间的关系及区别
- 當 Alexa 遇上 ESP8266 (一)
- TPS和QPS的区别和理解【转】
- 最小生成树入门(克鲁斯卡尔+普利姆 hdu1233)
- Spring源码-循环依赖源码解读
- xml转Map,对象,Map转xml,inputs tram 转xml 字符串的工具类方法
- 【LeetCode 234_链表】Palindrome Linked List
- 使用pyquery是遇到的一个403的问题
- VUE递归树形目录(vue递归组件)的使用
- 使用原生JavaScript实现对select增加option标签并附加value属性
热门文章
- C++随笔:从Hello World 探秘CoreCLR的内部(1)
- JAVA GUI编程学习笔记目录
- HIVE教程
- 验证管理员权限(C#)
- Configure a bridge interface over a VLAN tagged bonded interface
- RTP与RTCP协议介绍(转载)
- hive
- 搭建一套自己实用的.net架构(3)续 【ORM Dapper+DapperExtensions+Lambda】
- ASP.NET 5 Beta 7 版本
- SiteMap 提交,并使用正确的方式提交给搜索引擎