se7enxf / pyside2 Goto Github PK
View Code? Open in Web Editor NEWPython爱好者的Qt入门手册
Python爱好者的Qt入门手册
因为最近在学习Pyside2的使用,我使用的是4k屏幕,笔记本(缩放250%),如果Qtdesigner直接绘制出来的图预览大小是缩放后的,大小是正常的,但是生成代码直接运行后,就会变得非常小,在网上搜索到的解决方案是:
if __name__ == '__main__':
# from Pyside2 import QtCore
# 设置允许高分辨率缩放
QtCore.QCoreApplication.setAttribute(QtCore.Qt.ApplicationAttribute.AA_EnableHighDpiScaling)
app = QtWidgets.QApplication(sys.argv)
window = MainWindow()
window.window_init()
window.show()
sys.exit(app.exec_())
需要在创建app之前加入上面的语句
发现了个bug,可能版本不同了吧。在Lesson02中使用以下命令生成的ui_mainwindow.py
文件是用utf-16编码,导致执行main.py的时候报错。
pyside2-uic [你保存的文件名].ui > ui_mainwindow.py
搜索后发现,将>
改成-o
即可使用utf-8编码
本打算在第九课讲这个的,但是一直失败,就只能拿之前写的浏览器代码来充数了。。。
我是用的代码根据Qt官网改写的:
# 这是一个空的widget
widget = QtWidgets.QWidget()
widget_layout = QtWidgets.QVBoxLayout()
videoWidget = QVideoWidget()
widget_layout.addWidget(videoWidget)
widget.setLayout(widget_layout)
player = QMediaPlayer()
player.setVideoOutput(videoWidget)
player.setMedia(QUrl.fromLocalFile("example.mp4"))
player.play()
代码开头的widget
是放置在主窗口内的,运行程序没有报错也没声音和图像。So can you help help me?
Markdown的每个符号, 都是有其语义的(就像HTML标签一样)
另外,不同的部分在文章中的顺序, 也可以规范一下。 例如参考文献一般在后面。
把第一篇文章修改了一下, 大概长这样:
这里可以写一下, 这篇文章主要的目的是什么
操作系统相关环境
关于Python的安装请自行学习,这里不再累述。
安装PySide2的PyPI,命令行:
pip install --index-url=http://download.qt.io/snapshots/ci/pyside/5.11/
latest/ pyside2 --trusted-host download.qt.io*
bash指令可以放在code代码块里面。
万程开头helloworld!作者编写的的这个helloworld.py是根据官网教程改编的,里面也写了详细的注释。
此方法,只使用编写代码来实现Qt窗口。当我们设计复杂且美观的窗口时,只使用代码来编写必定是非常繁琐的。
因此,在下一讲中,会介绍一种结合QtDesigner的用户界面绘制方法,能让我们更高效的实现QtUI。
当你配置好环境,可以直接运行helloworld.py,如果成功运行并显示如下窗口,那么恭喜你入坑!
我在使用connectSlotsByName
方法进行槽连接时,发现不能传参。求助。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.