怎样搭建Qt for Python开发环境

 时间:2026-02-15 21:39:02

1、按住win+R键,输入cmd打开命令行工具。在命令行中输入python -V 后回车,查看自己电脑中python版本是否符合安装要求。

怎样搭建Qt for Python开发环境

2、在命令行中输入 pip install PySide2 从pip包管理软件进行安装下载。成功安装后,会有如图片所示 "successfully installed PySide2-5.12.0" 出现。

怎样搭建Qt for Python开发环境

怎样搭建Qt for Python开发环境

3、在搜索栏输入IDLE,打开python 自带的 IDLE 工具。新建一个脚本文件并保存为helloworld.py.

怎样搭建Qt for Python开发环境

4、在代码输入栏写上如下代码:

import sys

import random

from PySide2 import QtCore, QtWidgets, QtGui

class MyWidget(QtWidgets.QWidget):

    def __init__(self):

        super().__init__()

        self.text = QtWidgets.QLabel("Hello World")

        self.text.setAlignment(QtCore.Qt.AlignCenter)

        self.layout = QtWidgets.QVBoxLayout()

        self.layout.addWidget(self.text)

        self.setLayout(self.layout)

if __name__ == "__main__":

    app = QtWidgets.QApplication([])

    widget = MyWidget()

    widget.resize(400, 300)

    widget.show()

    sys.exit(app.exec_())

怎样搭建Qt for Python开发环境

5、点击 Run -> Run Module 对程序进行运行,会出现一个带有Helloword字样的界面。

怎样搭建Qt for Python开发环境

怎样搭建Qt for Python开发环境

  • VBA如何统计成绩不合格人数?
  • excel vba如何在指定位置插入指定格式的行
  • Excel VBA 怎么禁用所有应用程序加裁项
  • 怎样使用VBA保存时自动备份文件?
  • EXCEL函数 Choose功能及语法结构
  • 热门搜索
    兔子的尾巴有什么作用 管制是什么意思 什么软件可以借钱 三牛念什么 收养应当遵循什么原则 plant是什么意思 望穿秋水是什么意思 修罗是什么意思 7月5日是什么星座 犊子是什么意思