PDA

View Full Version : QDialog as top level and child dialogs not showing



ntp
24th December 2008, 23:51
I am using a class that inherits from QDialog as my top-level dialog and I want to have it show children dialogs. I am not creating these child dialogs on the stack but they are not showing up. I want to be able to show dialogs and potentially have those dialogs show other dialogs. I didn't chose QMainWindow because I don't want a tool bar, menu bar, or any of the other things that go with a QMainWindow.

I think I know the answer to this but do I need to have my toplevel window (the one that I call from my main()) be a QMainDialog instead of a QDialog?

thanks (and Happy holidays!)

jpn
26th December 2008, 00:16
Any QWidget can be shown as a window. QMainWindow is not mandatory at all. It just provides support for such things as menubar, toolbars, dock widgets etc. The problem must lie somewhere in your code, so could you show us the relevant parts?

ntp
30th December 2008, 01:40
Thanks. It turns out that if I don't specify the main dialog as the parent (use NULL instead for the parent widget), it does show up. the downside is that I don't get any control over the window (it is not recognizing mouse events).

I've done a custom work on this dialog so that must be the cause of the parenting issue. If I can manage to make a small working example, I'll post it.

ntp
4th January 2009, 00:40
another note in case anyone else runs into this.

My other problem was that I had set my main dialog to be modal. I thought that setting any other dialogs to non-modal would co-exist with that. It didn't. The answer is to make the main dialog non-modal (which it is by default) and any dialog that I want to be modal, to specifically set it modal through setModal(true).

wysota
4th January 2009, 02:14
Actually it's best to simply call exec() on dialogs you want to be modal instead of calling show(). Remember that modality is a relation term meaning that a window is modal relative to another window - it means the other window won't accept events as long as the modal dialog is open. This of course propagates, so if all your windows are modal to the ones that called them, only the last created window will accept input events. When you close it then its parent will accept input events, then its parent, etc.