System: 15.10 (Wily Werewolf) x64
Code:
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'test.ui'
#
# Created by: PyQt5 UI code generator 5.5.1
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(400, 300)
self.pushButton = QtWidgets.QPushButton(Form)
self.pushButton.setGeometry(QtCore.QRect(120, 120, 85, 26))
self.pushButton.setObjectName("pushButton")
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.pushButton.setText(_translate("Form", "PushButton"))
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
ex = Ui_Form()
ex.show()
sys.exit(app.exec_())
I get the following error:
app = QtGui.QApplication(sys.argv)
AttributeError: 'module' object has no attribute 'QApplication'
Basically, I designed the GUI with the Qt5 and then used pyuic5. I already installed PyQt5, not sure if the installation went through as expected.
UI Design:
Any help will be highly appreciated.
In PyQt5 the QApplication
method is not supported to be used with QtGui
instead it can be used with QtWidgets
. Try to rewrite your code like
app = QtWidgets.QApplication(sys.argv)
if using PyQt5 instead of PyQt4. It should probably work.
Other attributes like which i know QStyleFactory
has also changed to be used with QtWidgets
.
Hope this may solve your problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With