Qt World Summit: Submit your Presentation

QKeyEvent::isAutoRepeat() not working when cross-compiled (win32)

  • I am using the QKeyEvent::isAutoRepeat() function, and it works nicely when compiled on Windows using the minGW that was installed with the Qt SDK. The executable asks for these dlls:

    However, my build system needs to cross-compile this on Linux, for which I'm using the mingw32 installed by "yum install mingw32*". This executable asks for different dlls:

    All other Qt dlls are the same, so this problem seems to be not with Qt itself, but with the mingw32 cross-compiler. I know it's a long shot, but I thought I would try these forums and see if anyone has a suggestion.

    The problem is that with the cross-compiled mingw32 version, QKeyEvent::isAutoRepeat() simply does not work (it always returns false).

    Additionally, I have an action in my main menu with a shortcut key registered, and while that action is disabled I should get keyPressEvents for that key to my widget (at least this is what happens on Linux, Mac, and with the natively compiled Win32 build). However, with the cross-compiled build the keyPressEvents never arrive, as if the menu action was still enabled.

    If anyone has something to suggest I would be glad to hear it, thanks!

  • Well I spent an entire day tracking this down...

    It seems that the mingw32 cross-compiler on Fedora Linux does not deal with bitfields correctly. The problem is caused by the autorepeat member of the QKeyEvent class being declared as:

    uint autor:1;

    I have absolutely no idea why this is necessary - anyone?!? Both of the problems I mention above go away if this member is changed to:

    bool autor;

    Given that this problem was not manifesting on Linux, Mac, or the native minGW compiler, I would conclude that the cross-compiler version of mingw is at fault. For some reason, even with the same compiler and source code, sizeof(QKeyEvent) according to the DLL is 28 bytes, while my program says it's 32 bytes.

Log in to reply