Reputation: 21
While executing following snippet of code I am getting TypeError as follows:
TypeError: arguments did not match any overloaded call:
QAction(QObject): argument 1 has unexpected type 'str' QAction(str, QObject): argument 2 has unexpected type 'Ui_MainWindow'
QAction(QIcon, str, QObject): argument 1 has unexpected type 'str'
Can anyone help me regrading this? I'm pretty new to this thing, Thanks in advance!!
Code snippet:
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
##
#......some more codes
##
QtCore.QMetaObject.connectSlotsByName(MainWindow)
#app.aboutToQuit.connect(self.closeEvent)
quit = QAction("Quit", self)
quit.triggered.connect(self.closeEvent)
menubar = self.menuBar()
fmenu = menubar.addMenu("File")
fmenu.addAction(quit)
def retranslateUi(self, MainWindow):
## codes
def closeEvent(self, event):
choice = QtGui.QMessageBox.question(self.centralwidget,"Quit message","Are you sure you want to leave?",QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
if choice == QtGui.QMessageBox.Yes:
event.accept()
else:
event.ignore()
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
Upvotes: 1
Views: 958