Skip to content
Advertisement

Get the value of the pressed button for QMessageBox addButton function

I am trying to write a function to better manage QMessageBoxes for the program I am designing. It takes a number of parameters and creates a custom QMessageBox based on those parameters.

JavaScript

A simple form this function would be called will be like this:

JavaScript

However, I am having trouble getting the value of the pressed button. I have tried the following solution but it did not fix my problem.

  1. JavaScript

This would pass the value of the button to a function, but I want to access the value of the clicked button in my alert() function.

Advertisement

Answer

You have to use the clickedButton() method that returns the pressed button.

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement