已有环境简介:ubuntu16.04; python3; pip3; vscode
1.安装PyQt5和PyQt5-tools(Qtdesigner)
sudo pip3 install pyqt5 -i https://pypi.tuna.tsinghua.edu.cn/simple
sudo pip3 install PyQt5-tools
安装完毕后
输入代码,运行测试
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
from PyQt5.QtWidgets import QApplication, QWidget
if __name__ == '__main__':
app = QApplication(sys.argv)
w = QWidget()
w.resize(250, 150)
w.move(300, 300)
w.setWindowTitle('Simple')
w.show()
sys.exit(app.exec_())
成功可见一个窗口
错误解决:
qt.qpa.plugin:Could not load the Qt platform plugin “xcb“
添加环境变量查看错误原因:
export QT_DEBUG_PLUGINS=1
查看错误中缺少的包,去包位置:
cd /home/brainiac/Qt/Tools/QtCreator/lib/Qt/plugi