Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Get a window back on normal level after put it on top level
Qt 6.11 is out! See what's new in the release blog

Get a window back on normal level after put it on top level

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 2 Posters 3.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    adinon
    wrote on last edited by
    #1

    Hello guys!
    On my window i have a checkbox button that allows me to put the window on top level when it is checked and on normal window when it is unchecked. This is how i am trying to reach that but it is not working.
    Thanks for help!!

        Qt::WindowFlags flags = this->windowflags();
               if(ui->istopLvlcheckBox->isChecked()){
                   flags |= Qt::WindowStaysOnTopHint;
                }else{
                    flags &= ~Qt::WindowStaysOnTopHint;
                }
                this->setWindowFlags(flags);
               this->show();
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Can you check the window flag example to see it's working properly ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A Offline
        A Offline
        adinon
        wrote on last edited by
        #3

        First of all thanks for your reply. I already tried that example and when I check the <<Window stays top>> checkbox it goes to top level but when I unchecked or check <<Window stays bottom>> checkbox it still says top level.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Which OS/Qt version are you running ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • A Offline
            A Offline
            adinon
            wrote on last edited by
            #5

            Ubuntu 16.04 LTS
            Qt Creator 4.0.3
            Based on Qt 5.7.0 (GCC 4.9.1 20140922 (Red Hat 4.9.1-10), 64 bit)

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              That's the Qt Creator version, which one is Qt itself ?

              Also, can you test the same thing with your distribution provided Qt ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • A Offline
                A Offline
                adinon
                wrote on last edited by
                #7

                I am using Qt 5.7.0.
                I did test it but it is the same result.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Try adding the Qt::X11BypassWindowManagerHint to your calls changing the flags.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    adinon
                    wrote on last edited by
                    #9

                    According to the documentation Qt::X11BypassWindowManagerHint means that the window will be borderless
                    and that is exactly what it becomes when I add that flag. The point is when i try to debug the code in my first message like this (qDebug() << windowFlags() ), I have something like this:

                    • when the checkbox is checked:
                    QFlags<Qt::WindowType>(Window|X11BypassWindowManagerHint|WindowTitleHint|WindowSystemMenuHint|WindowMinMaxButtonsHint|WindowStaysOnTopHint|WindowCloseButtonHint|WindowFullscreenButtonHint) 
                    

                    --when it is unchecked :

                    QFlags<Qt::WindowType>(Window|X11BypassWindowManagerHint|WindowTitleHint|WindowSystemMenuHint|WindowMinMaxButtonsHint|WindowCloseButtonHint|WindowFullscreenButtonHint)
                    

                    As you can see when it is unchecked there is no WindowStaysOnTopHint flag anymore but i do not know why it is not working.

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Might be related to QTBUG-53711

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      2
                      • A Offline
                        A Offline
                        adinon
                        wrote on last edited by
                        #11

                        Thank for all your replies by the way.

                        1 Reply Last reply
                        1

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved