我在 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&)'
最佳答案
我现在在Ubuntu 13.10上也遇到类似的问题,并且已经成功编译了我的应用程序。问题是添加记录器引擎时收到的SIGSEGV
QxtBasicFileLoggerEngine *dbg = new QxtBasicFileLoggerEngine("debug.log");
// qxtLog takes ownership of dbg - no need to manage its memory
qxtLog->addLoggerEngine("dbg", dbg);
为了做到这一点,我从命令行使用QT4编译了所有内容(不要使用qmake,默认情况下使用qt5):
qmake-qt4
make
因此,这似乎确实是qt5库和qt4库的怪异组合(libqxt似乎是用/编译的)。不幸的是,我没有其他选择可以使用qt4来在Ubuntu上编译项目。我不知道规范中是否存在问题。
希望这可以节省一些麻烦并消除一些挫败感。我很惊讶地看到几乎没有人抱怨这个问题。