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. Qt window on top of virtual keyboard
Qt 6.11 is out! See what's new in the release blog

Qt window on top of virtual keyboard

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 4 Posters 4.2k Views 2 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
    alecs26
    wrote on last edited by alecs26
    #1

    Hello,

    I have a Qt window that I want to stay on top of everything. I have done that with

    flags: Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.WindowTransparentForInput
    

    However, it does not stay on top of all windows. For instance, it does not stay over virtual keyboards (for instance the default windows osk keyboard, which is a keyboard on the screen).

    I have tried

    flags: Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.WindowTransparentForInput| Qt.X11BypassWindowManagerHint
    

    but it does not work either.

    There seems to have some anwers in the following forum but I don't understand where to put these code lines and how.
    http://stackoverflow.com/questions/3316350/active-windows-in-windows-and-qwidgetactivatewindow

    I am on Windows10 with Qt5 QML Controls 2.

    Thank you very much for your help !

    Alex

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      I do not think u can be on top of osk.exe
      At least not via Qt . Maybe with tricks or timer
      Also not even OTHER OSK apps can be over it so it seems really special :)

      https://blogs.msdn.microsoft.com/oldnewthing/20110310-00/?p=11253

      Can i ask, what is the use case?

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

        Thank you for your answer.

        I have a circle following the mouse but when I get over the osk keyboard it gets under the keyboard.

        However it get under other virtual keyboard as well so I am pretty sure there is a way to get "more on top" that I am now.
        There seems to have some anwers in the following forum but I don't understand where to put these code lines and how.
        http://stackoverflow.com/questions/3316350/active-windows-in-windows-and-qwidgetactivatewindow

        Thank you !

        Alex

        mrjjM 1 Reply Last reply
        0
        • A alecs26

          Thank you for your answer.

          I have a circle following the mouse but when I get over the osk keyboard it gets under the keyboard.

          However it get under other virtual keyboard as well so I am pretty sure there is a way to get "more on top" that I am now.
          There seems to have some anwers in the following forum but I don't understand where to put these code lines and how.
          http://stackoverflow.com/questions/3316350/active-windows-in-windows-and-qwidgetactivatewindow

          Thank you !

          Alex

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #4

          @alecs26

          Well i use a tool
          https://www.savardsoftware.com/turbotop/
          to make my command prompt stay on top.

          Even if its on top of all else. Not the osk.

          So i doubt that
          AllowSetForegroundWindow(ASF_ANY);
          SetForegroundWindow();
          can fix it.

          To call them, you must include windows.h
          and maybe link to some dll. (user32)
          which dll is shown in MS docs.

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

            Perfect, thank you.

            I would still like to try AllowSetForegroundWindow(ASF_ANY); and SetForegroundWindow();
            So I guess I should call them in my main.cpp where I create the window ? I have:
            QQmlComponent componentmain(&engine,QUrl(QStringLiteral("qrc:/main.qml")));
            otherfunctions.objectmain=componentmain.create();

            I can then just type:
            AllowSetForegroundWindow(ASF_ANY);
            SetForegroundWindow();

            and it would apply to all windows ?
            Or can I do this in the window QML code ?

            Thank you !

            mrjjM 1 Reply Last reply
            0
            • A alecs26

              Perfect, thank you.

              I would still like to try AllowSetForegroundWindow(ASF_ANY); and SetForegroundWindow();
              So I guess I should call them in my main.cpp where I create the window ? I have:
              QQmlComponent componentmain(&engine,QUrl(QStringLiteral("qrc:/main.qml")));
              otherfunctions.objectmain=componentmain.create();

              I can then just type:
              AllowSetForegroundWindow(ASF_ANY);
              SetForegroundWindow();

              and it would apply to all windows ?
              Or can I do this in the window QML code ?

              Thank you !

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #6

              @alecs26

              Hi
              Im pretty sure you cannot call native api from QML
              but in main.cpp should be fine.

              Just tried with
              AllowSetForegroundWindow(ASFW_ANY );
              SetForegroundWindow((HWND)this->winId());

              for a mainwindow and its still not over OSK

              Maybe other will have a hint :)

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

                @mrjj thank you for your answer.
                Just a small last thing. I tried the following code but I get an error for "SetForegroundWindow" :
                error: invalid use of 'this' in non-member function SetForegroundWindow((HWND)this->winId());
                I think it's a basic thing but I don't know what to do :(

                int main(int argc, char *argv[])
                {
                    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
                    QGuiApplication app(argc, argv);
                
                    QQmlApplicationEngine engine;
                
                    QQmlComponent componentmain(&engine,QUrl(QStringLiteral("qrc:/main.qml")));
                    QObject *objectmain;
                    objectmain=componentmain.create();
                        
                    AllowSetForegroundWindow(ASFW_ANY);
                    SetForegroundWindow((HWND)this->winId());
                    
                    return app.exec();
                }
                

                Thanks !

                Alex

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

                  Hi,

                  Because this is the current instance of a class with the methods of said class.

                  If you want to get a WinID, you have to get the one from you application main window.

                  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
                  1
                  • A Offline
                    A Offline
                    alecs26
                    wrote on last edited by
                    #9

                    @SGaist I am very sorry for this basic question but from the following code, how can I get the WinId ?
                    I tried objectmain.WinId and componentmain.WinId but neither worked.

                    Thank you so much !

                    Alex

                    int main(int argc, char *argv[])
                    {
                        QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
                        QGuiApplication app(argc, argv);
                    
                        QQmlApplicationEngine engine;
                    
                        QQmlComponent componentmain(&engine,QUrl(QStringLiteral("qrc:/main.qml")));
                        QObject *objectmain;
                        objectmain=componentmain.create();
                            
                        AllowSetForegroundWindow(ASFW_ANY);
                        SetForegroundWindow((HWND)this->winId());
                        
                        return app.exec();
                    }
                    
                    jsulmJ 1 Reply Last reply
                    0
                    • A alecs26

                      @SGaist I am very sorry for this basic question but from the following code, how can I get the WinId ?
                      I tried objectmain.WinId and componentmain.WinId but neither worked.

                      Thank you so much !

                      Alex

                      int main(int argc, char *argv[])
                      {
                          QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
                          QGuiApplication app(argc, argv);
                      
                          QQmlApplicationEngine engine;
                      
                          QQmlComponent componentmain(&engine,QUrl(QStringLiteral("qrc:/main.qml")));
                          QObject *objectmain;
                          objectmain=componentmain.create();
                              
                          AllowSetForegroundWindow(ASFW_ANY);
                          SetForegroundWindow((HWND)this->winId());
                          
                          return app.exec();
                      }
                      
                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @alecs26 You cannot use this outside a class (C++ basics). As @SGaist already said you need to use your main window instead of this.

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      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