First of all you should not return anything from a void function (on_okButton_clicked). The proper way to close the dialog and return from exec() is to call accept() or reject(). This will terminate the exec with a return code of QDialog::Accepted or QDialog::Rejected.

You can use signal/slot as zibicoder suggested, but it's not very convenient.

The "usual" method to do it is to create separate getters for the actual values. The invocation would then look something like this: