Results 1 to 3 of 3

Thread: Qt Application Windows Always on Top of External Application Windows

  1. #1
    Join Date
    Sep 2015
    Location
    Ontario, Canada
    Posts
    28
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Qt Application Windows Always on Top of External Application Windows

    I have a program in Qt which has a main QMainWindow which creates other QMainWindows that it is the parent of. The problem is all the child QMainWindows are always on top of the parent QMainWindow and any application window from my application is always on top of any other window on the system that isn't part of my application unless the minimize button is pressed on my application.

    I just want my application to be like a normal application where whichever window you select is brought to the front, and if a window from another application on the computer is selected then that window goes on top of my application since my application no longer has focus.

    I've tried doing a findall in the project and removed all instances of raise(), lower(), and activateWindow() but nothing has changed so far and I doubt this is standard Qt behavior. Is there any other functions that I may be calling that would affect the window ordering? Alternatively is there a signal that QMainWindow has that I may be missing that is emitted when the window gains or loses focus so I can manually bring them to the front when they get focus, and lower the application somehow when none of my application windows have focus?

    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: Qt Application Windows Always on Top of External Application Windows

    I think your problem is partly due to making the additional QMainWindow instances children of the first QMainWindow. So long as any of those children has focus, it will be on top of the first QMainWindow and all of its siblings. If you want all of your QMainWindows to act independently of each other, you need to create them as full-fledged top-level windows, just like your first QMainWindow. That means creating them parentless (which effectively makes the desktop their parent). You should then be able to raise and lower them individually. You'll have to pay attention to the quitOnLastWindowClosed() slot to make sure you don't end up with a zombie process that continues running even though no windows are visible.

    I don't know about the issue of your application windows being on top of other app windows. Could be that fixing the parenting issue might fix that too.

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

    TEAmerc (14th April 2016)

  4. #3
    Join Date
    Sep 2015
    Location
    Ontario, Canada
    Posts
    28
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt Application Windows Always on Top of External Application Windows

    I changed the child windows to be their own top level windows like you suggested and that fixed my problem of the secondary windows always being on top of the primary window.

    Also I found the reason my application was always above any other application was due to a Qt::WindowStaysOnTopHint flag I had set in the primary window while trying to fix this a long time ago and I guess I had forgotten about it when it didn't correct my issue and didn't notice it created the new issue either.

    Thanks for the help!

Similar Threads

  1. 64 bit application for Windows using QT library
    By ilgale in forum Qt Programming
    Replies: 10
    Last Post: 4th June 2016, 16:57
  2. Replies: 10
    Last Post: 7th July 2015, 09:12
  3. Replies: 4
    Last Post: 4th September 2012, 19:05
  4. Replies: 3
    Last Post: 12th July 2010, 06:25

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.