Reputation: 2396
please note: qt/c++ newbie here
Purpose:
I have a QDialog from which I want to return a result. I am aware of the QDialog::exec()
which combined with setResult, results in the use of Accept()
or Reject()
,
but as the documentation page reads, the developers suggest to sue the QDialog return codes, implying that different values can be used although I have had no luck with this.
enum ReturnResult{
success=0,
fail=1
error=2
warning=3
}
How may I use the QDialog::setResult()
function to send custom enum
values to (as seen above),
as a result, back to the parent class, if this is not possible, any suggestion as to how I may solve this problem?
Upvotes: 1
Views: 2776
Reputation: 5836
You can call QDialog::done(int res)
to close a dialog with the desired result code, which then will be the return value of QDialog::exec()
.
Upvotes: 1
Reputation: 16421
The documentation for result()
states that
In general returns the modal dialog's result code,
Accepted
orRejected
.
If I understand correctly, that means that even if the current implementation allows passing custom values, you cannot be certain that it won't change and break your code in the future.
In your case, simply add another signal to it and connect to it, or add your own field to your dialog and use it to pass the data.
Upvotes: 0