Results 1 to 8 of 8

Thread: How to get focus back to main window if non-modal dialog is closed?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to get focus back to main window if non-modal dialog is closed?

    The title bar close tool should trigger closeEvent() when clicked. I guess you want to intercept that and hide() the dialog then ignore the event. Your dialog also has a hideEvent() that you could use.

    Closing the window does not destroy the object unless you have set the relevant window Qt::WA_DeleteOnClose attribute. In the typical main() the first main window is allocated on the stack and is not destroyed until the exec() loop exits after all the top-level windows close.

  2. The following user says thank you to ChrisW67 for this useful post:

    Cupidvogel (1st January 2016)

Similar Threads

  1. Replies: 2
    Last Post: 4th August 2010, 19:10
  2. Replies: 3
    Last Post: 1st February 2009, 15:49
  3. Replies: 5
    Last Post: 4th August 2006, 23:44
  4. Replies: 3
    Last Post: 23rd July 2006, 18:02
  5. cannot make a main window modal
    By Dark_Tower in forum Qt Programming
    Replies: 12
    Last Post: 23rd March 2006, 10:21

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
  •  
Qt is a trademark of The Qt Company.