zoukankan      html  css  js  c++  java
  • 记录一下使用qt designer和pyqt5做界面的过程

    安装PyQt5

    pip install PyQt5 -i https://pypi.douban.com/simple

    安装QTdesigner

    pip install PyQt5-tools -i https://pypi.douban.com/simple

    打开QTdesigner

    我的位于下面的目录
    D:Anaconda3Libsite-packagespyqt5_toolsQtindesigner.exe
    如果报错
    需要将
    D:Anaconda3Libsite-packagesPyQt5Qtpluginsplatforms
    复制到
    D:Anaconda3Libsite-packagespyqt5_toolsQtinplatforms
    就ok了

    Ubuntu特殊情况

    如果报错

    qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
    This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
    
    Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.
    
    Aborted (core dumped)
    

    需要终端加入

    export QT_DEBUG_PLUGINS=1
    

    再运行程序进行调试
    查看输出的结果。

    解决方案

    sudo apt install --reinstall libxcb-xinerama0
    

    可能用到的

    sudo ln -sf /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/ /usr/bin/
    
    sudo apt-get install qt5-default qttools5-dev-tools
    
    sudo apt-get install python3-pyqt5
    
    
    sudo apt-get install libx11-dev libxext-dev libxtst-dev
    sudo apt-get install xlibmesa-gl-dev libglu1-mesa-dev
    
    sudo ln -sf /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/ /usr/bin/
    
    sudo apt-get install libcap2-bin
    

    设计界面

    设计完成后,保存为.ui文件
    在终端中输入命令
    pyuic5 .untitled.ui -o none2.py(pyuic5.bat在conda库中存在)

    修改py文件

    文件上部加入

    from PyQt5 import QtCore, QtGui, QtWidgets
    from PyQt5.QtWidgets import QMainWindow, QWidget, QApplication
    import sys
    

    下部加入

    if __name__ == "__main__":
        app = QApplication(sys.argv)
        mainWindow = QMainWindow()
        ui = Ui_MainWindow()
        ui.setupUi(mainWindow)
        mainWindow.show()
        sys.exit(app.exec_())
    

    展示一下结果

  • 相关阅读:
    开源程序postGIS为postgresql提供存储空间地理数据的支持
    oracle官方文档
    postgresql转换符
    【转】oracle的Interval类型详解
    [转]千万不要把灯泡放进嘴里
    服务器运维指令
    莫名其妙的时区问题
    Linux内存思想
    oracle提高查询效率24法
    哈佛大学图书馆凌晨4点的景象
  • 原文地址:https://www.cnblogs.com/superfly123/p/13351621.html
Copyright © 2011-2022 走看看