随笔分类 - QML
摘要:1、背景 采用quickwidget+qml方式,在qml里生成了Image,希望在c++里传入图片路径,qml显示 2、问题 传入相对路径,显示失败;传入普通的绝对路径也显示失败 3、解决 在c++里将相对路径转化为绝对路径,并且加上制定的前缀发给qml显示 C++: QString path =
        阅读全文
            
摘要:1、QQmlApplicationEngined搭配 Window示例: #include <QGuiApplication> #include <QQmlApplicationEngine> int main(int argc, char *argv[]) { QGuiApplication ap
        阅读全文
            
摘要:一、动态加载和实例化对象:createComponent 例子1: ①、创建本地的QML文件,注意文件第一个字母要大写 ZStation.qml import QtQuick 2.5 Rectangle{ property string mName: "station" signal entered
        阅读全文
            
摘要:在父窗口设置: color: Qt.rgba(0,0,0,0) 如: Rectangle{ color: Qt.rgba(0,0,0,0) width: 860 height: 710 id: root; } opacity这个属性是对当前组件以及子组件都设置不透明度,所以不太适用,color: Q
        阅读全文
            
摘要:1、下图是用qml画的,用 QQuickWidget承载,假设程序初始化这个界面放在StackedWidget的1界面 2、切换到StackedWidget的2界面 3、再切换到StackedWidget的1界面,qml消失 此问题出现在Qt5.6.1,同样的代码Qt5.10没问题
        阅读全文
            
摘要:QtObject { Component.onCompleted: console.log("Completed")//构造函数 Component.onDestruction: console.log("Destruction")//析构函数 }
        阅读全文
            
摘要:1、效果 2、与swipview一起使用 //index提示器 PageIndicator { id: indicator count: swipeView.count currentIndex: swipeView.currentIndex anchors.bottom: parent.botto
        阅读全文
            
摘要:1、效果 2、自定义路径qml import QtQuick 2.0 Item { property point startPoint: Qt.point(0, 0) property point endPoint: Qt.point(0, 0) property var lineColor: "#
        阅读全文
            
摘要:1、简单的json MouseArea { anchors.fill: parent; onClicked: { var json = '{"result":true, "count":42}'; var obj = JSON.parse(json); console.log(obj.count);
        阅读全文
            
摘要:一、适用情况 在C++里将数据生成,然后将这个数据设置为qml的上下文属性,在qml里就能使用了 二、传递基础类型 1、main.cpp QQuickWidget *m_widget = new QQuickWidget(this); m_widget->setGeometry(0, 0, this
        阅读全文
            
摘要:MouseArea { anchors.fill: parent; hoverEnabled: true; cursorShape: (containsMouse? (pressed? Qt.ClosedHandCursor: Qt.OpenHandCursor): Qt.ArrowCursor);
        阅读全文
            
摘要:1、代码 import QtQuick 2.0 import QtQuick.Controls 2.0 Rectangle { id:root; color: "#19192C"; property int rect_width: 80; property int rect_height: 20; 
        阅读全文
            
摘要:SwipeView { id: swipeView z:0; width: parent.width-listView.width; height: parent.height; anchors.left: listView.right; interactive: false;//禁止手拖动 cur
        阅读全文
            
摘要:RadioButton { id:root2 checked: false property color checkedColor: "#E5F012" property int node_id: 2; onClicked: { if(root2.checked) { swipeView.curre
        阅读全文
            
摘要:1、例子1 import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Layouts 1.0 import QtQuick.Window 2.2 Window { visible: true width: 300 height: 45
        阅读全文
            
摘要:import QtQuick 2.0 import QtQuick.Controls 2.0 Rectangle { id:root; color: "#19192C"; property int rect_width: 50; property int rect_height: 20; prope
        阅读全文
            
摘要:一、静态生成两个界面 import QtQuick.Controls 2.2 import QtQml 2.2 import QtQuick 2.9 ApplicationWindow { title: qsTr("Hello World") width: 640 height: 480 visib
        阅读全文
            
摘要:一、例子 1、例子1:基本使用 import QtQuick 2.0 import QtCharts 2.2 Rectangle { id: root property string info: "info" color: "#000C3C" width: 600; height: 400; fun
        阅读全文
            
摘要:一、同一层 与代码编写顺序相反,如下图构造顺序是:item_2->item_1 ps:虽然item_2比item_1先构造,但是布局的时候item_1可以使用其他item_2的属性【x、y等】 二、不同层 从外到里,如下图构造顺序是:rect1->rect_1 三、QML继承 //A.qml Ite
        阅读全文
            
 
                    
                