Results 1 to 5 of 5

Thread: QDialog as top level and child dialogs not showing

  1. #1
    Join Date
    Jul 2007
    Location
    California, USA
    Posts
    62
    Thanks
    17
    Thanked 7 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question QDialog as top level and child dialogs not showing

    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!)
    Last edited by ntp; 24th December 2008 at 23:52. Reason: spelling error

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QDialog as top level and child dialogs not showing

    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?
    J-P Nurmi

  3. #3
    Join Date
    Jul 2007
    Location
    California, USA
    Posts
    62
    Thanks
    17
    Thanked 7 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QDialog as top level and child dialogs not showing

    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.

  4. #4
    Join Date
    Jul 2007
    Location
    California, USA
    Posts
    62
    Thanks
    17
    Thanked 7 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QDialog as top level and child dialogs not showing

    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).

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QDialog as top level and child dialogs not showing

    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.

Similar Threads

  1. Qdialog as a child widget
    By dave in forum Newbie
    Replies: 12
    Last Post: 14th November 2006, 10:43

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.