Results 1 to 4 of 4

Thread: Qt5 and modal windows

  1. #1
    Join Date
    May 2009
    Posts
    49
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Qt5 and modal windows

    I have a QFrame displayed as a subwindow (so it doesn't have a taskbar button) and also modal, with no parent.

    In Qt4, when pressing on the application taskbar button the frame is always on top of the application. Also this happens when choosing another application then coming back to my application.

    In Qt5 however, when I press on my application button, the main window comes on top, hiding the modal frame, making the application unusable, since the modal frame is behind, so I can only close it from the task manager.

    This is what I'm using:

    Qt Code:
    1. setWindowFlags(Qt::FramelessWindowHint | Qt::SubWindow);
    2.  
    3. setWindowModality(Qt::ApplicationModal);
    To copy to clipboard, switch view to plain text mode 

    I'm absolutely sure it's a Qt5 problem, because I use the exact same code with both versions

    Any idea how can I make this thing behave sanely in Qt5?

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,387
    Thanks
    247
    Thanked 687 Times in 677 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Qt5 and modal windows

    Maybe you also need Qt::WindowStaysOnTopHint. Or simply give your dialog a parent - being parentless is the root cause of your problem; if it were a child of your main widget, it would always be on top.

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

    Carlsberg (5th May 2013)

  4. #3
    Join Date
    May 2009
    Posts
    49
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt5 and modal windows

    I've tried Qt::WindowStaysOnTopHint too, what that does is making the frame to stay on top of everything, not only my application. Also, it can't have a parent, because then it will be limited to the parent. The root cause i Qt5, but I have no idea why...


    Added after 39 minutes:


    Ok, I've added a parent and the flag Qt::Window and it works. Thanks
    Last edited by Carlsberg; 5th May 2013 at 20:19.

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt5 and modal windows

    It should be enough to derive your window from QDialog instead of QWidget (e.g. put a QFrame in QDialog).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Qt non modal form how to
    By ras in forum Qt Programming
    Replies: 0
    Last Post: 5th August 2010, 19:20
  2. QWidget "allways on top + modal to all windows"
    By boblatino in forum Qt Programming
    Replies: 2
    Last Post: 24th July 2010, 19:30
  3. Modal dialog should not get hide behind windows task bar
    By sanjayshelke in forum Qt Programming
    Replies: 0
    Last Post: 11th September 2009, 16:08
  4. Qt Modal/Modeless possible bug in MS Windows
    By Daliphant in forum Qt Programming
    Replies: 1
    Last Post: 11th June 2008, 17:41
  5. Bug with modal windows on Mac? [Qt 3.3]
    By kalos80 in forum Qt Programming
    Replies: 0
    Last Post: 15th February 2008, 16:52

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.