随笔分类 -  QML

摘要:import QtQuick 2.9 import QtQuick.Window 2.2 import QtQuick.Controls 2.2 import QtGraphicalEffects 1.0 import QtQuick.Layouts 1.3 ApplicationWindow { id: root visible: true width: Screen.... 阅读全文
posted @ 2019-07-25 23:56 朱小勇 阅读(2739) 评论(0) 推荐(0)
摘要:如果是在windows系统下,则最终打包成exe windeployqt xxx.exe -qmldir C:\Qt\Qt5.9.6\5.9.6\mingw53_32\qml 注意使用Qt自己的cmd执行 阅读全文
posted @ 2019-07-25 23:43 朱小勇 阅读(886) 评论(0) 推荐(0)
摘要:Component.onCompleted: { root.visibility = Window.Maximized} Component.onCompleted: { root.showMaximized() } 阅读全文
posted @ 2019-07-25 16:35 朱小勇 阅读(1001) 评论(0) 推荐(0)
摘要:需要: import QtGraphicalEffects 1.0 阅读全文
posted @ 2019-07-25 16:33 朱小勇 阅读(671) 评论(0) 推荐(0)
摘要:AnimatedImage { anchors.fill: parent source: "qrc:/img/timg.gif" } 阅读全文
posted @ 2019-07-25 14:49 朱小勇 阅读(1599) 评论(0) 推荐(0)
摘要:一、C++的信号和QML的槽 前言: Qt中的信号与槽,通常是一个信号SIGNAL和一个槽SLOT,通过connet连接,而QML中不需要再写槽函数,只需要在合适的地方告诉QML:如果x信号产生则执行x 如有信号: Class A{ signals: void rcvData(QString str 阅读全文
posted @ 2019-07-25 11:42 朱小勇 阅读(8238) 评论(0) 推荐(0)
摘要:一、常用宏 1、信号与槽 C++类中的信号与槽都可以在QML中访问 2、C++类的成员函数,Q_INVOKABLE Q_INVOKABLE void function(); 3、C++类的枚举,Q_ENUMS Q_ENUMS (enumName) 4、C++的属性,Q_PROPERTY Q_PROP 阅读全文
posted @ 2019-07-24 23:28 朱小勇 阅读(2061) 评论(0) 推荐(0)
摘要:一、Row 1、说明 类似于Qt设计师中的水平布局,可以当做Item先anchor设置位置,再加入Item控件。 ps:Row不会改变里面控件的大小,即没有自适应这一说法 手册: 2、示例 二、Column 1、说明 类似于Qt设计师中的水平布局,可以当做Item先anchor设置位置,再加入Ite 阅读全文
posted @ 2018-08-11 14:44 朱小勇 阅读(277) 评论(0) 推荐(0)
摘要:1、定义 可以把Loader当做一个占位符,即占有屏幕的某一个空间,当加载了组件之后,这个空间就能显示相应的图形了。所以可以给Loader设置anchor布局 2、加载组件 source:加载QML文档 sourceComponent:加载Component组件 注意:同一时刻只能加载一个对象,加载 阅读全文
posted @ 2018-08-11 11:29 朱小勇 阅读(925) 评论(0) 推荐(0)
摘要:1、属性 interval:int 间隔时间 repeat:bool 是否重复 running:bool 查询当前状态 triggeredOnStart:bool 定时器开启即运行一次回调 2、信号 triggered 间隔时间到了发出此信号 3、方法 restart 重启 start 开启 sto 阅读全文
posted @ 2018-08-10 10:33 朱小勇 阅读(461) 评论(0) 推荐(0)
摘要:ApplicationWindow需要导入QtQuick.Controls Window需要导入QtQuick.Window 。 默认不可见,需要设置visible:true才可见。 主要区别就是ApplicationWindow提供了简单的方式创建程序窗口,因为其有属性menuBar、toolBa 阅读全文
posted @ 2018-08-07 17:06 朱小勇 阅读(3592) 评论(0) 推荐(0)
摘要:1、使用的是Component+自定义信号+Connections 2、在任意地方定义信号 阅读全文
posted @ 2018-08-06 20:07 朱小勇 阅读(386) 评论(0) 推荐(0)
摘要:1、例子1,简单使用Connections import QtQuick 2.6 import QtQuick.Window 2.2 import QtQuick.Controls 1.4 Window { visible: true width: 640 height: 480 title: qs 阅读全文
posted @ 2018-08-06 17:10 朱小勇 阅读(5712) 评论(0) 推荐(0)
摘要:2、AnchorLine 上面的AnchorLine就是某一个Item的top、bottom...... 阅读全文
posted @ 2018-08-06 16:56 朱小勇 阅读(951) 评论(0) 推荐(0)
摘要:QML从ECMAScript继承而来,所以支持这个ECMAScript。经常在QML工程中看到Math、Data.....等方法,但是在Qt手册里搜索不到,这是因为这些方法不是QtQuick的,而是ECMAScript的。 ECMAScript+QtQuick=QML 阅读全文
posted @ 2018-08-06 14:58 朱小勇 阅读(384) 评论(0) 推荐(0)
摘要:1、QML rect.color = Qt.rgba(Math.random(), Math.random(), Math.random(), 1);//random返回0~1的随机数 2、Qt QColor clr(rand() % 256, rand() % 256, rand() % 256) 阅读全文
posted @ 2018-08-06 13:58 朱小勇 阅读(2053) 评论(0) 推荐(0)
摘要:1、概念 Component只能包含一个顶层的Item,而且在这个Item之外不能定义任何的数据,除了Id。 Component通常用来给一个View提供图形化组件。 Component不是Item的派生类,而是从QQmlComponent继承而来的,虽然它通过自己的顶层Item为其他的View提供 阅读全文
posted @ 2018-08-02 09:48 朱小勇 阅读(3363) 评论(0) 推荐(0)
摘要:1、console.log("123"); 2、console.log("a is ", a, "b is ", b); 3、打印代码块时间 console.time("wholeFunction"); //代码块 console.timeEnd("wholeFunction"); 4、打印执行次数 阅读全文
posted @ 2018-08-01 16:11 朱小勇 阅读(4596) 评论(0) 推荐(0)
摘要:一、如下图.. 二、 1、FileDialog 阅读全文
posted @ 2018-08-01 15:05 朱小勇 阅读(483) 评论(0) 推荐(0)
摘要:在同一个qml文件中,如果同时import了Qtquick1和2,那么谁在后面,谁起作用 阅读全文
posted @ 2018-07-26 18:00 朱小勇 阅读(1030) 评论(0) 推荐(0)