编译器看不到 QX11Info
Compiler does not see QX11Info
我创建了一个小类来设置一些全局快捷方式。但是现在,当我编译我的应用程序时,我看到许多错误:
In file included from ../src/GlobalShortcut/globalshortcut_linux.h:7:0,
from moc_globalshortcut_linux.cpp:9:
../../../QtStable/5.4/gcc_64/include/QtWidgets/qstyleoption.h:117:9: error: expected identifier before numeric constant
None = 0x00,
^
../../../QtStable/5.4/gcc_64/include/QtWidgets/qstyleoption.h:117:9: error: expected '}' before numeric constant
../../../QtStable/5.4/gcc_64/include/QtWidgets/qstyleoption.h:117:9: error: expected unqualified-id before numeric constant
In file included from ../../../QtStable/5.4/gcc_64/include/QtCore/qglobal.h:1085:0,
from ../src/GlobalShortcut/globalshortcut_linux.h:4,
from moc_globalshortcut_linux.cpp:9:
../../../QtStable/5.4/gcc_64/include/QtWidgets/qstyleoption.h:121:36: error: 'FrameFeature' was not declared in this scope
Q_DECLARE_FLAGS(FrameFeatures, FrameFeature)
^
当我发表评论时,我的类错误消失了。这是:http://pastebin.com/k5qSvqDn
好的,我从QWidget而不是QMainWindow继承了类(我不知道为什么:D),现在我有另一个错误:
mainwindow.o: In function `X11ShortCut::addShortCut(QKeySequence, QString)':
globalshortcut_linux.h:30: undefined reference to `QX11Info::display()'
globalshortcut_linux.h:31: undefined reference to `QX11Info::appRootWindow(int)'
globalshortcut_linux.h:31: undefined reference to `QX11Info::display()'
globalshortcut_linux.h:32: undefined reference to `QX11Info::display()'
在我的 .pro 文件中,我添加了LIBS += -lX11
,它没有帮助。
那么,问题出在哪里呢?
我没有检查过,但我相信您只是错过了将以下内容添加到您的.pro
文件中,如文档中所述
QT += gui x11extras
您可能缺少头文件,但是如果没有错误消息,我发现很难弄清楚,因为我从未直接接触过X11的东西。
希望对您有所帮助。
> Vinicius接近得到完整的答案。
这适用于Qt 5.1或更高版本。问题是删除了对 X11 和 GDI 句柄的访问,然后又放回了稍微不同的位置。
将 x11extras 添加到 .pro 文件:
QT += gui x11extras
如果 moc 生成的代码无法编译,请将以下内容添加到它包含的文件的底部(X11 标头定义 Bool):
#undef Bool
将以下内容添加到需要访问 QX11info 的文件中:
#include <QtX11Extras/qx11info_x11.h>
相关文章:
- 我不断收到 [错误] ID 返回 1 退出状态错误,但看不到问题所在
- 看不到文件'SDL2.lib'
- WSL 看不到环境变量
- 为什么我的 FreeRTOS 任务看不到类成员?
- Google Colab 看不到 .so 文件
- 派生类看不到基类成员
- 为什么我看不到字符串?
- CMake 看不到SDL2_PATH环境变量 (Windows)
- OpenMP 任务看不到共享变量的更改
- handleMessage看不到我的类和函数
- 为什么 connect() 函数看不到插槽?
- 模板类看不到继承的模板成员
- 为什么即使链接器找到目标文件,我的程序也看不到函数定义?
- 将 somedialog.h 包含在项目的其他部分中会使编译器看不到 ui_somedialog.h
- SFML - 代码::块看不到 sfml 图形(等)文件
- CMake 看不到源文件,找不到 #includes
- ifstream在OSX上看不到新内容
- C++概念看到我的类型的函数,但看不到 std::vector 的函数
- unique_ptr看不到派生类的自定义构造函数
- 编译器看不到 QX11Info