Yes/No message box using QMessageBox

前端 未结 7 2180
渐次进展
渐次进展 2021-01-30 05:59

How do I show a message box with Yes/No buttons in Qt, and how do I check which of them was pressed?

I.e. a message box that looks like this:

7条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-30 06:44

    Python equivalent code for a QMessageBox which consist of a question in it and Yes and No button. When Yes Button is clicked it will pop up another message box saying yes is clicked and same for No button also. You can push your own code after if block.

    button_reply = QMessageBox.question(self,"Test", "Are you sure want to quit??", QMessageBox.Yes,QMessageBox.No,)
    
    if button_reply == QMessageBox.Yes:
        QMessageBox.information(self, "Test", "Yes Button Was Clicked")
    else :
        QMessageBox.information(self, "Test", "No Button Was Clicked")
    
    

提交回复
热议问题