丰宁
deepin
2025-07-29 15:08 1.确保插件是否安装
sudo apt-get install libxcb-xinerama0 libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-render-util0 libxcb-shape0 libxcb-sync1 libxcb-xfixes0 libxcb-xinput0
2.程序中在调用qt前加入如下代码
# This Python file uses the following encoding: utf-8
import os
import sys
if sys.platform=="win32":
os.environ["QT_QPA_PLATFORM"] ="windows"
elif sys.platform=="linux":
os.environ["QT_QPA_PLATFORM"] = "xcb"
from PySide6.QtWidgets import QApplication, QWidget
# Important:
# You need to run the following command to generate the ui_form.py file
# pyside6-uic form.ui -o ui_form.py, or
# pyside2-uic form.ui -o ui_form.py
from ui_form import Ui_Widget
class Widget(QWidget):
def __init__(self, parent=None):
super().__init__(parent)
self.ui = Ui_Widget()
self.ui.setupUi(self)
if __name__ == "__main__":
app = QApplication(sys.argv)
widget = Widget()
widget.show()
sys.exit(app.exec())
Reply Like 0 View the author


中文 
今天想在deepin下学习一下python ,安装QT creator,打开示例运行一下,结果:

刚开始学习就卡在这里了,请教各位大神,如何解决?