Skip to content Skip to sidebar Skip to footer

AttributeError: Module 'PyQt5.QtGui' Has No Attribute 'QWidget'

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, and one button. W

Solution 1:

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.


Post a Comment for "AttributeError: Module 'PyQt5.QtGui' Has No Attribute 'QWidget'"