PyQt5 failing import of QtGui

后端 未结 1 1468
醉酒成梦
醉酒成梦 2020-12-01 10:11

I\'ve just moved from PyQt4 to 5 and I\'m having an issue with QtGui. I installed using the 32bit windows installer, not my own build.

when I do:

         


        
相关标签:
1条回答
  • 2020-12-01 11:13

    Assuming everything was installed correctly, you need to adjust your imports slightly to port from PyQt4 to PyQt5.

    The main GUI elements are in the QtWidgets module, whilst the more basic GUI elements are in QtGui. See the Qt modules page for more details.

    The example code needs to be changed to something like:

    from PyQt5 import QtCore, QtGui, QtWidgets
    
    class MainWindow(QtWidgets.QMainWindow, UI.MainUI.Ui_MainWindow):
        ...
    

    For more details on porting from PyQt4 to PyQt5, see: Differences Between PyQt4 and PyQt5.

    0 讨论(0)
提交回复
热议问题