Using QxtGlobalShortcut and getting error

  • I started a new GUI Application in Qt Creator and, to get QxtGlobalShortcut working, I followed the directions located here:

    In mainwindows.cpp I added:
    @#include <QxtGlobalShortcut>@

    Below this:

    I pasted their example:

    @ QxtGlobalShortcut* shortcut = new QxtGlobalShortcut(window);
    connect(shortcut, SIGNAL(activated()), window, SLOT(toggleVisibility()));

    In the projects .pro file below this:

    @QT += core gui@

    I added this:

    @CONFIG += qxt
    QXT += core gui@

    At the bottom of the .pro file I added this:
    @INCLUDEPATH += C:\Qt\libqxt\src\gui
    INCLUDEPATH += C:\Qt\libqxt\src\core
    INCLUDEPATH += C:\Qt\libqxt\include\QxtGui@

    The errors I am getting are:

    @error: no matching function for call to 'QxtGlobalShortcut::QxtGlobalShortcut(<unresolved overloaded function type>)'
    QxtGlobalShortcut* shortcut = new QxtGlobalShortcut(window);
    error: no matching function for call to 'MainWindow::connect(QxtGlobalShortcut*&, const char*, <unresolved overloaded function type>, const char*)'
    connect(shortcut, SIGNAL(activated()), window, SLOT(toggleVisibility()));@

    Also, in their example, I changed the pointer "window" to "this" and I get this crazy error:

    @error: undefined reference to `_imp___ZN17QxtGlobalShortcutC1EP7QObject'@

    So I am stuck now. What am I doing wrong or what am I missing?

    Thank you!

  • Lifetime Qt Champion

    Since you had to add the include path I wonder if Qxt is installed properly these lines

    @CONFIG += qxt
    QXT += core gui@

    should have been enough. If it's not the case, you might either add the path to the libQxt prf files to your environment variable or add the missing path and libraries to your LIBS variable

  • I think Qxt is not installed properly.

    The first step from here: "": is ensure qmake is in the path and then run configure.bat.

    When I run that I get these kinds of errors:

    bq. Testing for Berkeley DB...
    mingw32-make -f Makefile.Release clean
    mingw32-make[1]: Entering directory 'C:/Qt/libqxt/config.tests/db'
    del release\main.o
    Could Not Find C:\Qt\libqxt\config.tests\db\release\main.o
    mingw32-make[1]: Leaving directory 'C:/Qt/libqxt/config.tests/db'
    mingw32-make -f Makefile.Debug clean
    mingw32-make[1]: Entering directory 'C:/Qt/libqxt/config.tests/db'
    del debug\main.o
    Could Not Find C:\Qt\libqxt\config.tests\db\debug\main.o
    mingw32-make[1]: Leaving directory 'C:/Qt/libqxt/config.tests/db'
    mingw32-make -f Makefile.Release
    mingw32-make[1]: Entering directory 'C:/Qt/libqxt/config.tests/db'
    compiling main.cpp
    main.cpp:1:16: fatal error: db.h: No such file or directory
    #include <db.h>
    .file "main.cpp"
    compilation terminated.

  • Lifetime Qt Champion

    If you don't use any database stuff from Qxt you can just disable it

  • I was having troubles with this Qxt also. I have instead started to create my own class, I am just stuck on how I should connect functions to the hotkey, might finish it tomorrow. Here is what I have so far "SystemHotkey":

  • I don't know if you still are looking for a global hotkey solution but here is a class I put together for myself; "QSystemHotkey": There is an example application in the repository also.

    Please feel free to make it better!

  • Thanks Brandon but I've given up on qt and just went back to AutoHotkey. Thanks though.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.