PDA

View Full Version : cannot make a main window modal



Dark_Tower
14th March 2006, 09:23
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.

zlatko
14th March 2006, 09:27
You must use QDialog instead QMainWindow

Dark_Tower
14th March 2006, 09:37
You must use QDialog instead QMainWindow

I need to use a main window with status bar, tool bar, etc

zlatko
14th March 2006, 09:51
try use Qt::WType_Dialog

Dark_Tower
14th March 2006, 10:14
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 :confused:

Dark_Tower
14th March 2006, 10:19
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?

wysota
14th March 2006, 11:28
You can just hide() the parent window when you show() the child window and show() the parent back when the child is close()d.

Dark_Tower
14th March 2006, 11:58
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.

Dark_Tower
22nd March 2006, 15:06
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.

Dark_Tower
22nd March 2006, 16:55
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.

jacek
22nd March 2006, 17:27
Hi, I put this thread some days ago in the newbie forum
Please, don't start multiple threads on the same problem.

Dark_Tower
22nd March 2006, 18:24
Ok sorry jacek

Dark_Tower
23rd March 2006, 10:21
Finally it works, the problem was that I call to setWindowModality after calling show :mad: