Important: Please read the Qt Code of Conduct -

How to make Qquickview doesn't obtain focus ?

  • I want to make a Input Method Editor(IME) .
    The IME send text to another application which has the input coursor .
    I called the Win-API as below:

    INPUT input[2];
        memset(input, 0, 2 * sizeof(INPUT));
        input[0].type = INPUT_KEYBOARD;
        input[0].ki.wVk = 'K';
        SendInput(1, input, sizeof(INPUT));
        input[1].type = INPUT_KEYBOARD;
        input[1].ki.wVk = 'K';
        input[1].ki.dwFlags = KEYEVENTF_KEYUP;
        SendInput(1, input + 1, sizeof(INPUT));

    It can work when I call those code every seconds with timer(The ‘k’ can be sent to the editor which coursor is flashing).

    But when I show my Quickview window with hotkey, it can't work.
    I know may be my quickview window obtained focus at that moment, but at that time the input coursor
    is flashing at other window. So it confused me, I have no idea about this……

  • I found a way like this, and it works:

        InputWindow *inputWind = new InputWindow();
        HWND wid = (HWND)(inputWind->winId());
        SetWindowLong(wid, GWL_EXSTYLE, GetWindowLong(wid, GWL_EXSTYLE) | WS_EX_NOACTIVATE | WS_EX_COMPOSITED);

    Through this way, make the window can't obtain focus, and the sendinput works.
    But I don't know if this is good enough.

Log in to reply