Converting a qframe to a qdialog - missing exec() - How to block until a window is closed
I ran into a problem whereby I created a class that derived from QFrame and later realized I should have subclassed the QDialog class. I worked around this by just creating a new QDialog-based form, and copy/pasted the QFrame GUI items to the newly created QDialog *.ui form.
If I wanted to stay with a QFrame, I would need to block until the frame window was closed. After the "window" (QFrame) is closed I then want to call methods get pull the data from the object.
(Q) How can I block until a QFrame is closed? I looked for exec() or something like "wait" but didn't find it.
Is there a way to simulate the QDialog::exec() function on a QFrame-based form?
It sounds like you're creating a dialog so I would suggest to use the right tools for the job and stick with QDialog. It has more than just exec() compared to QFrame. Its frame is styled properly. It closes on "esc" pressed. It has accept() and reject() methods and more.
About every time I've seen a custom dialog created the right base was QDialog, but if you really wanted to re-invent the wheel you could just create a method called exec() and use "QEventLoop::exec":http://doc.qt.io/qt-5/qeventloop.html inside to start a local event loop and connect its quit() slot to whatever exit apparatus you design for your widget e.g. closing it.