内容简介:首先创建一个python文件,说明:然后创建qml文件:
首先创建一个 python 文件, test.py
:
from PyQt5.QtGui import QGuiApplication from PyQt5 import QtQml if __name__ == '__main__': path = 'qml/test.qml' app = QGuiApplication([]) engine = QtQml.QQmlApplicationEngine() engine.load(path) app.exec_()
说明:
app = QGuiApplication([]) QtQml.QQmlApplicationEngine() engine.load(path) app.exec_()
然后创建qml文件:
import QtQuick 2.3 import QtQuick.Controls 1.2 ApplicationWindow { id: test visible: true width: 100; height: 100 Text { text: "hello world!"; } }
说明:
-
visible: true
是必须的,否则application不会显示 -
创建了一个
Text
组件来显示hello world
直接运行, python test.py
,就可以看到熟悉的 hello world
了。
:
http://zgljl2012.com/pyqt5-qml-18xing-dai-ma-shi-xian-hello-worldru-men/
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- PHP代码审计之入门实战
- Android 代码布局 —— 从入门到放弃(一)
- 由表生成代码:mybatis-generator入门
- 四段代码入门Go协程以及channel!
- VMProtect 3.3.1虚拟机&代码混淆机制入门
- 半小时入门Rust,这是一篇Rust代码风暴
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Mobilizing Web Sites
Layon, Kristofer / 2011-12 / 266.00元
Everyone has been talking about the mobile web in recent years, and more of us are browsing the web on smartphones and similar devices than ever before. But most of what we are viewing has not yet bee......一起来看看 《Mobilizing Web Sites》 这本书的介绍吧!