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
Forum Updated to NodeBB v4.3 + New Features

Qt window on top of virtual keyboard

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 4 Posters 3.4k 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 12 Feb 2017, 12:59 last edited by alecs26 2 Dec 2017, 13:05
    #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
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 12 Feb 2017, 13:24 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 12 Feb 2017, 13:57 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

        M 1 Reply Last reply 12 Feb 2017, 14:06
        0
        • A alecs26
          12 Feb 2017, 13:57

          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

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 12 Feb 2017, 14:06 last edited by mrjj 2 Dec 2017, 14:06
          #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 12 Feb 2017, 14:10 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 !

            M 1 Reply Last reply 12 Feb 2017, 14:12
            0
            • A alecs26
              12 Feb 2017, 14:10

              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 !

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 12 Feb 2017, 14:12 last edited by mrjj 2 Dec 2017, 14:26
              #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 12 Feb 2017, 17:56 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 12 Feb 2017, 20:10 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 13 Feb 2017, 12:47 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 13 Feb 2017, 13:04
                    0
                    • A alecs26
                      13 Feb 2017, 12:47

                      @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 13 Feb 2017, 13:04 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

                      1/10

                      12 Feb 2017, 12:59

                      • Login

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