Results 1 to 13 of 13

Thread: cannot make a main window modal

  1. #1
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    38
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Unhappy cannot make a main window modal

    Hi, I have a main window that I initialize it at full screen. This window is child of another window. I want that this main window acts like a modal dialog window respect its parent. I've tried it setting its window modality to Qt::WindowModal or Qt::ApplicationModal but it doesn't work because when I minimize the main window, for example, I am still able to access to its parent window. Anybody knows how to make it?

    Thanks.
    Last edited by Dark_Tower; 14th March 2006 at 10:26.

  2. #2
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: cannot make a main window modal

    You must use QDialog instead QMainWindow
    a life without programming is like an empty bottle

  3. #3
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    38
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: cannot make a main window modal

    Quote Originally Posted by zlatko
    You must use QDialog instead QMainWindow
    I need to use a main window with status bar, tool bar, etc

  4. #4
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: cannot make a main window modal

    try use Qt::WType_Dialog
    a life without programming is like an empty bottle

  5. #5
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    38
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: cannot make a main window modal

    Quote Originally Posted by zlatko
    try use Qt::WType_Dialog
    Could it work, but It doesn't . The main window is closed automaticaly when I set it to dialog type. I think that one of the problems comes from that a main window is always a top level window because when I close its parent window, the main window is still running. Maybe a main window can never be modal, but it's strange

  6. #6
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    38
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: cannot make a main window modal

    Hi again, I've found a strange behaviour: if I set the main window to Window::modal and child of another window, when I minimize the main window with the button at the top of the window, its parent window appear. But if i hide the application and show it again and i try to minimize the main window its parent not appears and that's exactly what I want. So, the question is: how can I make that the parent window never appears even if I minimize the main window or reduze its size until I close the main window?
    Last edited by Dark_Tower; 14th March 2006 at 11:33.

  7. #7
    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: cannot make a main window modal

    You can just hide() the parent window when you show() the child window and show() the parent back when the child is close()d.

  8. #8
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    38
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: cannot make a main window modal

    Thanks wysota, I didnt' take account with this solution because I thought that when a window is hidden it don't queue connections but it's false.

  9. #9
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    38
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: cannot make a main window modal

    Hi again, sorry but I have to "reopen" this thread because I thought that hidin the parent window solves the problem, but now it doesnt' works until I have declared the parent windows as a dialog and I QDialog::exec it. Moreover, this dialog window is at the same time child of another window. I just want to know if you think that is possible to set a QMainWindow (child of a dialog, for example) modal or there's a reason that explains that it can't be modal, because I've tried it in a lot of ways but I haven't been succesful or maybe it's a kind of bug in Qt4.1.0, I really will apreciate if someone tells me if with the new version of Qt is posible to set a QMainWindow, child of a QDialog or even top level, modal (with access to all the other windows in the appliaction blocked).

    Thanks.
    Last edited by Dark_Tower; 22nd March 2006 at 17:09.

  10. #10
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    38
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default cannot make a main window modal

    http://www.qtcentre.org/forum/showthread.php?t=1219

    Hi, I put this thread some days ago in the newbie forum because I thought that it has an easy solution... but I still haven't found a reason that explains why the main window can't be modal.

    Anyone knows how to make it?

    Thanks.
    Last edited by Dark_Tower; 22nd March 2006 at 17:58.

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: cannot make a main window modal

    Quote Originally Posted by Dark_Tower
    Hi, I put this thread some days ago in the newbie forum
    Please, don't start multiple threads on the same problem.

  12. #12
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    38
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: cannot make a main window modal

    Ok sorry jacek

  13. #13
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    38
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: cannot make a main window modal

    Finally it works, the problem was that I call to setWindowModality after calling show

Similar Threads

  1. How to make window semi modal
    By kaushal_gaurav in forum Qt Programming
    Replies: 7
    Last Post: 29th August 2008, 09:27
  2. access main window from function
    By eric in forum Qt Programming
    Replies: 6
    Last Post: 19th January 2008, 22:29
  3. minimizing main window
    By eric in forum Qt Programming
    Replies: 4
    Last Post: 28th November 2007, 17:54
  4. Window OS make distclean && qmake && make one line
    By patrik08 in forum General Programming
    Replies: 4
    Last Post: 22nd March 2007, 11:43
  5. Compiling with Qmake/Make
    By VireX in forum Newbie
    Replies: 25
    Last Post: 22nd February 2007, 06:57

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.