Results 1 to 3 of 3

Thread: Multiple windows: hide parent when child shown, unhide when child closed

  1. #1
    Join Date
    Feb 2015
    Posts
    3
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Multiple windows: hide parent when child shown, unhide when child closed

    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,

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Multiple windows: hide parent when child shown, unhide when child closed

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

  3. The following user says thank you to d_stranz for this useful post:

    LostSoul (25th February 2015)

  4. #3
    Join Date
    Feb 2015
    Posts
    3
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Multiple windows: hide parent when child shown, unhide when child closed

    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.

Similar Threads

  1. Replies: 1
    Last Post: 22nd May 2011, 00:53
  2. Child-Parent Widget??
    By anupamgee in forum Qt Programming
    Replies: 1
    Last Post: 11th May 2009, 14:17
  3. Parent Child for window
    By febil in forum Qt Programming
    Replies: 6
    Last Post: 1st April 2009, 06:00
  4. Replies: 11
    Last Post: 4th June 2008, 08:22
  5. Hide/unhide paragraphs in QTextEdit
    By mcostalba in forum Qt Programming
    Replies: 4
    Last Post: 16th April 2007, 12:02

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.