Search code examples
qtprocessmove

Moving window "osk" in Qt application


I'm programming a tactile application in Qt and I use the virtual keyboard "osk" to permit the user to type text. I launch the "osk" with this code

QProcess process;
process.start("osk.exe");

The problem I have is that the size of my app is limited, so I would like to move the keyboard in order to it is centered in my app. Can I move it as I want ?


Solution

  • You may use Win32 API for that:

    #include "windows.h"
    
    
    HWND hwnd = FindWindow(0, L"On-Screen Keyboard");
    RECT rc;
    GetWindowRect(hwnd, &rc);
    MoveWindow(hwnd, 100, 100, rc.right-rc.left, rc.bottom-rc.top, true);
    

    This will move the window to (100,100) location.