buttonClicked() for button on QMessageBox
-
I am trying to call "removeDuplicate()" method on clicking 'Ok' button of QMessageBox. But when I click the button the method doesn't execute. What should I do?
Here is code snippet :def removeDuplicate(self): curItem = self.listWidget_2.currentItem() self.listWidget_2.takeItem(curItem) def error_popup(self): msg=QtWidgets.QMessageBox() msg.setText("You can't select more than one wicket-keeper.") msg.setWindowTitle(" ") msg.setIcon(QtWidgets.QMessageBox.Critical) x = msg.exec_() msg.setStandardButtons(QtWidgets.QMessageBox.Ok) msg.buttonClicked.connect(self.removeDuplicate) -
Hi
All setup including connect must come before
x = msg.exec_() -
You connect the slot after you executed / shown the message box - so what do you expect?
-
You connect the slot after you executed / shown the message box - so what do you expect?
@Christian-Ehrlicher I want the "removeDuplicate" method to be executed when I will click on the 'Ok' button. By this method I want to remove item from one QListWidget and add it to another one.
-
@Tejaswini_14 said in buttonClicked() for button on QMessageBox:
I want the "removeDuplicate" method to be executed when I will click on the 'Ok' button.
fine but this doesn't answer my question - when you first execute the dialog and only afterwards connect the signal once the dialog is already closed - how should it work?
-
Hi
All setup including connect must come before
x = msg.exec_() -
@mrjj Thanks a lot Sir!