Important: Please read the Qt Code of Conduct -


  • Данный код компилируется только для 32 битной системы, а на 64 битной выдаёт ошибку линковки LNK2019. Возможно ли как-то, используя функцию RegisterHotKey, использовать глобальные горячие клавиши для 64 битной системы?

    #include "mainwindow.h"
    MainWindow::MainWindow(QWidget *parent)
        : QMainWindow(parent)
        RegisterHotKey(HWND(MainWindow::winId()), 100, MOD_CONTROL, 'E');
    bool MainWindow::nativeEvent(const QByteArray &eventType, void *message, long *result)
        MSG* msg = reinterpret_cast<MSG*>(message);
        if(msg->message == WM_HOTKEY){
            if(msg->wParam == 100){
                return true;
        return false;

  • Hi, don't know any Russian, but I know what LNK2019 error means, add this line to your .pro file and run qmake again:

    LIBS += -luser32

  • @hskoglund unfortunately, it's not working.

  • Translate to english: This code is compiled only for a 32-bit system, and on a 64-bit system it gives an error link LNK2019. Is it possible, somehow, using the RegisterHotKey function, to use global hotkeys for a 64-bit system?

  • Aha, I see, yes you can do a RegisterHotKey() from a 32-bit Qt program and will it work fine both on 32-bit and 64-bit Windows.
    (I have written a similar program like yours and tested it on both 32-bit and 64-bit Windows 7 and 10.)

    Edit: to clarify, I used Qt 5.12.3 MSVC2017 32-bit to build my program (that uses RegisterHotKey()), then used windeployqt and copied it into both 32-bit and 64-bit Windows, worked on both :-)

  • @hskoglund Can you give me this code? Sorry for the delay, here allowed to write every ten minutes

  • Sure, but I have to clean it from some customer's data first, give me 15 minutes...

  • @Vladislav77 Made a .zip file for you with my project:

  • @hskoglund thank you!

  • @hskoglund Can you talk me, how using windeployqt in more detailed? What you copied into both 32-bit and 64-bit?

  • @Vladislav77 I have 3 computers, on the 1st, which is Windows7 SP1 64-bit, I have installed Visual Studio 2017 Community Edition and Qt 5.12.3 MSVC2017 32-bit. On that computer I build RegisterHotKeyDemo in 32-bit Release mode.

    Then I cd into the Release dir and delete all files except RegisterHotKeyDemo.exe, open a CMD window and type:
    \qt\5.12.3\msvc2017\bin\windeployqt.exe RegisterHotKeyDemo.exe

    Then I copy the 3 .dlls needed for 32-bit MSVC2017 runtime into the same directory:

    copy C:\windows\syswow64\ucrtbase.dll .
    copy C:\windows\syswow64\msvcp140.dll .
    copy C:\windows\syswow64\vcruntime140.dll .

    The final step, I copy the Release directory to my USB memory stick. I have 2 more computers, one 32-bit Windows 10 Home and one 64-bit Windows 10 Professional. On these 2 computers I have not installed Qt or Visual Studio (they are customer's computers).

    On both these computers I can insert my USB memory stick and start the RegisterHotKeyDemo.exe file inside the Release directory and the Ctrl-E hotkey works on both these computers :-)

  • @hskoglund Thank you, again

Log in to reply