[Seek Help] QT creator安装运行问题:Could not find the Qt platform plugin "dxcb"
Tofloor
poster avatar
刘政
deepin
2025-02-18 23:56
Author

今天想在deepin下学习一下python ,安装QT creator,打开示例运行一下,结果:
截图_选择区域_20250218235404.png

截图_选择区域_20250218235454.png

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

Reply Favorite View the author
All Replies
丰宁
deepin
2025-07-29 15:08
#1

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 View the author