【发布时间】:2013-05-05 18:05:59
【问题描述】:
我在 Qt5 应用程序中链接 libqxt 时遇到问题。
我在文档中编写了一个类似示例的代码,但我有错误。
QxtGlobalShortcut* shortcut = new QxtGlobalShortcut(this);
connect(shortcut, SIGNAL(activated()), this, SLOT(newScreenshoot()));
shortcut->setShortcut(QKeySequence("Ctrl+Shift+F12"));
我正在使用 Qt 5.0.1:
damian@damian-Lenovo-B560:~$ qmake --version
QMake version 3.0
Using Qt version 5.0.1 in /usr/lib/i386-linux-gnu
以及来自 Ubuntu 13.04 存储库的最新 libqxt-dev。
我有以下链接器错误:
/home/damian/Dokumenty/Programowanie/QShot/mainwindow.cpp:20: error: undefined reference to `QxtGlobalShortcut::QxtGlobalShortcut(QObject*)'
/home/damian/Dokumenty/Programowanie/QShot/mainwindow.cpp:22: error: undefined reference to `QxtGlobalShortcut::setShortcut(QKeySequence const&)'
【问题讨论】:
-
好像你没有链接 libqxt。仅包括库的标题只是两个步骤之一,链接它是第二个步骤。但是,我不知道该怎么做才能链接这个库,也许看看文档。
-
我已将 CONFIG += qxt QXT += core gui 添加到我的 *.pro 文件中,如文档中所述。
-
你能告诉我qmake的输出吗?你也用Qt4尝试过吗?也许 qxt 只与 Qt4 兼容(或者这个特定的库版本可能是用 Qt4 构建的......)
-
我刚刚发现libqxt本身是兼容Qt5的。但根据this package dependency listing 看来,Ubuntu 中提供的软件包是针对 Qt4 编译和链接的。这使得它无法与 Qt5 一起使用。所以你必须手动构建它,我猜...... :(
-
手动构建并不可怕。 (:我会尝试并回复我的进度。(: