QtQuick 技巧 4
来源:互联网 发布:淘宝ins是什么品牌 编辑:程序博客网 时间:2024/05/16 09:12
QtQuick 技巧 4
基于 QtQuick.Controls 1.x
QML 窗体透明
ApplicationWindow { flags: Qt.Window|Qt.FramelessWindowHint style: ApplicationWindowStyle { background: Item{ } }}
ApplicationWindow { flags: Qt.Window|Qt.FramelessWindowHint style: ApplicationWindowStyle { background: Rectangle{ color: "transparent" } }}
QML 不规则窗体
ApplicationWindow { flags: Qt.Window|Qt.FramelessWindowHint style: ApplicationWindowStyle { background: Image{ source: "不规则.png" } }}
ListView 注意事项
currentIndex
必需在 ListView::highlightRangeMode
设置为 ListView.StrictlyEnforceRange
才能实时更新,不然可能永远都是 0
。
Text 注意事项
自动分行,需要指明 Text::width
。不然分行没有参考值。
QtQuick 母版页
//~ Panel.qmlItem { property alias headerHeight: headerLoader.height property alias footerHeight: footerLoader.height property Component headerComponent: null readonly property Item headerItem: headerLoader.item Loader { id: headerLoader width: parent.width height: 40 sourceComponent: headerComponent Binding { target: headerLoader.item property: "anchors.fill" value: headerLoader } } property Component footerComponent: null readonly property Item footerItem: footerLoader.item Loader { id: footerLoader width: parent.width height: 40 anchors.bottom: parent.bottom Binding { target: footerLoader.item property: "anchors.fill" value: footerLoader } } property Component contentComponent: null readonly property Item contentItem: contentLoader.item Loader { id: contentLoader width: parent.width anchors.top: headerLoader.bottom anchors.bottom: footerLoader.top; Binding { target: contentLoader.item property: "anchors.fill" value: contentLoader } }}
使用:
Panel { headerComponent: Rectangle { color: "black" } footerComponent: Rectangle { color: "black" } contentComponent: ListView { delegate: Rectangle { width: parent.width; height: 40; color: "green" } model: 10 }}
全局单例模式
入口文件的
id
和属性静态 JavaScript 文件
qml 单例,QML 实现
qml 单例,c++ 实现
注册上下文属性
货币展示
/** * places 保留几位有效小数 * symbol 法币符号 * thousand 每千为分隔符 * decimal 数与小数分隔符 */Number.prototype.formatMoney = function (places, symbol, thousand, decimal) { places = !isNaN(places = Math.abs(places)) ? places : 2; symbol = symbol !== undefined ? symbol : "$"; thousand = thousand || ","; decimal = decimal || "."; var number = this, negative = number < 0 ? "-" : "", i = parseInt(number = Math.abs(+number || 0).toFixed(places), 10) + "", j = (j = i.length) > 3 ? j % 3 : 0; return symbol + negative + (j ? i.substr(0, j) + thousand : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousand) + (places ? decimal + Math.abs(number - i).toFixed(places).slice(2) : ""); };var revenue = 12345678;console.log(revenue.formatMoney()); // $12,345,678.00console.log(revenue.formatMoney(0, "HK$ ")); // HK$ 12,345,678
2 0
- QtQuick 技巧 4
- QtQuick 技巧
- QtQuick 技巧 2
- QtQuick 技巧 3
- QtQuick 技巧 5
- QtQuick 技巧6
- QtQuick 技巧 7
- QtQuick一分钟技巧:使用C++保存全局数据
- QtQuick大杂烩
- 杂烩:QWiget、QGraphics、QtQuick
- QtQuick 基础教程(一)
- QtQuick获取屏幕信息
- QtQuick TableView 操作
- Java Web 与 QtQuick
- QtQuick堆栈窗口
- QtQuick动态创建组件
- QtQuick UI 问答
- QtQuick学习整理
- Git中的库(repository)概述
- Android Journey: <<Head First Android Development>>
- 打开文件,写入数据(文件操作)
- eclipse之在线安装svn
- 剑指Offer面试题36(Java版):数组中的逆序对
- QtQuick 技巧 4
- Linux下编写程序必要工具使用详解
- sdut oj数据结构实验之链表五:单链表的拆分
- notes of Charlotte's Web Chapter 1
- ie浏览器flash player不能用的解决方案
- 新的开始 -- 2016年10月08日
- iOS开发陷阱之NSString - compare
- jQuery.unbind()
- 第61篇Chrome扩展蓝牙开发(一)