PDA

View Full Version : QWidget::exec() and QWidget::show()



MarkoSan
18th October 2007, 18:22
What is the difference between these two methods? Both display window ...

marcel
18th October 2007, 18:31
exec() blocks the application flow while show() doesn't.
exec is mainly used for modal dialogs.

MarkoSan
18th October 2007, 18:34
So, then:



QWidget::setModal(true);
QWidget::show();

and



QWidget:;exec();

are identical?

marcel
18th October 2007, 18:41
Not really.
After calling show() the program flow will continue.
When you call exec() it will not return until you close the dialog.

BTW, exec is available only for QDialog.

Why don't you check the docs about exec and show? They explain it very well.

MarkoSan
18th October 2007, 19:00
Yes, I am checking now, but just final question. So show method initiates its own thread or not?

high_flyer
18th October 2007, 20:28
no it doesn't.
Actually as far as I understand, QDialog::exec() does not either - it just intervenes in the vent loop and does not allow new events to get in - but I didn't check QDialogs code, so I am not 100% sure about this.

marcel
18th October 2007, 22:39
No, you're right. No thread is started by QDialog::exec nor show(). That would make no sense. The event loop of the parent window is used to process the dialog events.