AttributeError: module 'PyQt5.QtGui' has no attribute 'QWidget'

前端 未结 1 2008
一整个雨季
一整个雨季 2020-12-09 13:37

So, I\'m trying to make a UI for a python code I have, but keep stumbling up on problems...

Right now, all the code does is make a window, with 2 texteditor boxes, a

相关标签:
1条回答
  • 2020-12-09 13:57

    Your error is from here:

    Ui_Widget(QtGui.QWidget)
    

    It basically tells you what the problem is.

    It seems you are mixing some QT4 and QT5 here as your import is in QT5-style, but QtGui.QWidget looks like QT4-style.

    Replace the line with:

    Ui_Widget(QtWidgets.QWidget)
    

    which should be compatible according to the docs

    Remark: I don't know what you are really doing, but when you mention this: Even when I change class Ui_Widget(QtGui.QWidget): to class Ui_Widget(QtGui.QtWidgets): I get AttributeError: module 'PyQt5.QtGui' has no attribute 'QtWidgets' That's correct. You already imported QtWidgets, and not from PyQt5.QtGui. Just use Ui_Widget(QtWidgets) there.

    In short: all these errors seem to be related to refactoring in regards to the modules between QT4 and QT5. The docs should help.

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