随笔分类 - 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....
阅读全文
摘要:如果是在windows系统下,则最终打包成exe windeployqt xxx.exe -qmldir C:\Qt\Qt5.9.6\5.9.6\mingw53_32\qml 注意使用Qt自己的cmd执行
阅读全文
摘要:Component.onCompleted: { root.visibility = Window.Maximized} Component.onCompleted: { root.showMaximized() }
阅读全文
摘要:需要: import QtGraphicalEffects 1.0
阅读全文
摘要:AnimatedImage { anchors.fill: parent source: "qrc:/img/timg.gif" }
阅读全文
摘要:一、C++的信号和QML的槽 前言: Qt中的信号与槽,通常是一个信号SIGNAL和一个槽SLOT,通过connet连接,而QML中不需要再写槽函数,只需要在合适的地方告诉QML:如果x信号产生则执行x 如有信号: Class A{ signals: void rcvData(QString str
阅读全文
摘要:一、常用宏 1、信号与槽 C++类中的信号与槽都可以在QML中访问 2、C++类的成员函数,Q_INVOKABLE Q_INVOKABLE void function(); 3、C++类的枚举,Q_ENUMS Q_ENUMS (enumName) 4、C++的属性,Q_PROPERTY Q_PROP
阅读全文
摘要:一、Row 1、说明 类似于Qt设计师中的水平布局,可以当做Item先anchor设置位置,再加入Item控件。 ps:Row不会改变里面控件的大小,即没有自适应这一说法 手册: 2、示例 二、Column 1、说明 类似于Qt设计师中的水平布局,可以当做Item先anchor设置位置,再加入Ite
阅读全文
摘要:1、定义 可以把Loader当做一个占位符,即占有屏幕的某一个空间,当加载了组件之后,这个空间就能显示相应的图形了。所以可以给Loader设置anchor布局 2、加载组件 source:加载QML文档 sourceComponent:加载Component组件 注意:同一时刻只能加载一个对象,加载
阅读全文
摘要:1、属性 interval:int 间隔时间 repeat:bool 是否重复 running:bool 查询当前状态 triggeredOnStart:bool 定时器开启即运行一次回调 2、信号 triggered 间隔时间到了发出此信号 3、方法 restart 重启 start 开启 sto
阅读全文
摘要:ApplicationWindow需要导入QtQuick.Controls Window需要导入QtQuick.Window 。 默认不可见,需要设置visible:true才可见。 主要区别就是ApplicationWindow提供了简单的方式创建程序窗口,因为其有属性menuBar、toolBa
阅读全文
摘要:1、使用的是Component+自定义信号+Connections 2、在任意地方定义信号
阅读全文
摘要: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
阅读全文
摘要:2、AnchorLine 上面的AnchorLine就是某一个Item的top、bottom......
阅读全文
摘要:QML从ECMAScript继承而来,所以支持这个ECMAScript。经常在QML工程中看到Math、Data.....等方法,但是在Qt手册里搜索不到,这是因为这些方法不是QtQuick的,而是ECMAScript的。 ECMAScript+QtQuick=QML
阅读全文
摘要: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)
阅读全文
摘要:1、概念 Component只能包含一个顶层的Item,而且在这个Item之外不能定义任何的数据,除了Id。 Component通常用来给一个View提供图形化组件。 Component不是Item的派生类,而是从QQmlComponent继承而来的,虽然它通过自己的顶层Item为其他的View提供
阅读全文
摘要:1、console.log("123"); 2、console.log("a is ", a, "b is ", b); 3、打印代码块时间 console.time("wholeFunction"); //代码块 console.timeEnd("wholeFunction"); 4、打印执行次数
阅读全文
摘要:在同一个qml文件中,如果同时import了Qtquick1和2,那么谁在后面,谁起作用
阅读全文