日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

QML笔记-4中方式运行qml文件

發布時間:2025/3/15 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 QML笔记-4中方式运行qml文件 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

目錄

?

?

使用QQmlApplicationEngine運行qml

使用qml工具運行

使用qmlScene工具運行qml文件

使用QtQuick Prototype運行qml文件


?

使用QQmlApplicationEngine運行qml

程序結構如下:

源碼如下:

main.cpp

#include <QGuiApplication> #include <QQmlApplicationEngine>int main(int argc, char *argv[]) {QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);QGuiApplication app(argc, argv);QQmlApplicationEngine engine;engine.load(QUrl(QStringLiteral("qrc:/main.qml")));if (engine.rootObjects().isEmpty())return -1;return app.exec(); }

main.qml

import QtQuick 2.9 import QtQuick.Window 2.2Window {visible: truewidth: 640height: 480title: qsTr("Hello World")Text {anchors.centerIn: parentid: texttext: qsTr("Hello World")color: "red"font.pointSize: 30}Component.onCompleted: {console.debug("finished")} }

運行運行截圖都是;

?

?

使用qml工具運行

這里要先設置好環境變量,我的電腦Qt路徑如下:D:\Qt5.9\Qt\5.9.8\mingw53_32\bin

程序運行截圖如下:

?

使用qmlScene工具運行qml文件

?

使用QtQuick Prototype運行qml文件

程序運行截圖如下:

程序結構如下:

PrototypeDemo.qmlproject

/* File generated by Qt Creator */import QmlProject 1.1Project {mainFile: "PrototypeDemo.qml"/* Include .qml, .js, and image files from current directory and subdirectories */QmlFiles {directory: "."}JavaScriptFiles {directory: "."}ImageFiles {directory: "."}/* List of plugin directories passed to QML runtime */// importPaths: [ "../exampleplugin" ] }

PrototypeDemo.qml

import QtQuick 2.9 import QtQuick.Window 2.2Window {visible: truewidth: 640height: 480title: qsTr("Hello World")Text {anchors.centerIn: parentid: texttext: qsTr("Hello World")color: "red"font.pointSize: 30}Component.onCompleted: {console.debug("finished")} }

?

總結

以上是生活随笔為你收集整理的QML笔记-4中方式运行qml文件的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。