[Qt-interest] QDialog::exec VS QDialog::show
Nikos Chantziaras
realnc at arcor.de
Thu May 6 01:39:56 CEST 2010
On 05/06/2010 02:20 AM, yifli at mtu.edu wrote:
> Hi,
>
> What's the difference between the two functions?
>
> I created a dialog, which is supposed to show up when necessary later on.
>
> However, my program seems to like QDialog:exec() better, which brings the
> above question
With exec(), you can't interact with the dialog's parent or with the
rest of the application if it's parentless; it can't never get focus and
all input gets blocked. This kind of window is called "modal".
With show(), you can still use the parent window.
Which one you choose depends on the dialog's function. If you need to
block interaction with the dialog's parent or the whole application, you
use exec(). Otherwise, show(). show() can have some complications,
like being able to launch the same dialog multiple times which might not
be what you want. In those cases, instead of creating another dialog,
you can just shift focus to it and raise it instead.
More information about the Qt-interest-old
mailing list