PDA

View Full Version : Multiple windows: hide parent when child shown, unhide when child closed



LostSoul
25th February 2015, 14:01
Hi,

Is there any way of unhiding a window when I close another? I am new to QT/C++ and this issue has me stumped!

My app has a main selection window with buttons that takes you to a full screen search window. If the user exits the search screen (via Close button) the main selection window should be present again. I can achieve this currently by not hiding the main selection window but if the user moves the search window they can see the main selection (they cannot interact with it though). I can hide the main selection when the user opens the search but I am not able to get it back again later.

To call the second window I connect a button to a function. I have tried closeEvents but I am not sure how to detect it in firstwindow.cpp.

Any pointers to where I can find the information on how to do this is appreciated. I have scoured this forum and other forums but can find nothing to help.

Thanks,

d_stranz
25th February 2015, 18:13
When you hide a parent window, all of its child windows are also hidden. If you want to hide and unhide windows, they either must be siblings (each children of the same parent) or be unrelated.

You can implement closeEvent() for your search window to emit a signal that says "I'm about to close". Connect that signal to a slot in your main window that calls show().

LostSoul
25th February 2015, 18:18
d_stranz,

Thanks for the reply. I was just about to post that I had solved the issue by doing exactly that. It has taken me a while to get the signals/slots to actually work but I am glad to say that it does.