QDialog dialog; int result = dialog.exec(); if (result == QDialog::Accepted) { // User clicked "OK" // Do something... } else { // User clicked "Cancel" // Do something else... }In this example, we create a new QDialog and then use the `exec()` function to show it as a modal dialog. The `exec()` function blocks the program until the user closes the dialog. We then check the result of the dialog using the `result` variable. If the user clicked "OK", the `result` variable will be `QDialog::Accepted`, and we can execute some code. If the user clicked "Cancel", the `result` variable will be `QDialog::Rejected`, and we can execute some different code. The QDialog result function is part of the Qt GUI library, which is a C++ library for building cross-platform desktop applications.