C++ 编译器没有看到QX11Info

C++ 编译器没有看到QX11Info,c++,qt,x11,C++,Qt,X11,我创建了一个小类来设置一些全局快捷方式。 但现在,当我编译我的应用程序时,我看到了许多错误: 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: e

我创建了一个小类来设置一些全局快捷方式。 但现在,当我编译我的应用程序时,我看到了许多错误:

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)
                                    ^
当我发表评论时,我的类错误消失了。 这是:

好的,我从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
文件中,正如在

很可能您丢失了一个头文件,但是如果没有错误消息,我发现有点难以理解,因为我从未直接接触过X11内容


希望能有所帮助。

维尼修斯即将得到完整答案

这适用于Qt 5.1或更高版本。问题是,对X11和GDI句柄的访问被删除,然后又放回一个稍有不同的位置

将x11extras添加到.pro文件:

QT += gui x11extras
若moc生成的代码未能编译,请将以下内容添加到它包含的文件底部(X11头定义Bool):

将以下内容添加到需要访问QX11Info的文件中:

#include <QtX11Extras/qx11info_x11.h>
#包括

尝试重新排序您的
#include
指令。将所有与X11相关的头放在源文件的最后。错误是某些X11头添加了
#define None
,破坏了对任何后续头的解析。非常感谢!您保存了我的项目:)我收到一个错误,
:-1:error:QT:x11extras中的未知模块
知道如何删除此错误吗?
#undef Bool
#include <QtX11Extras/qx11info_x11.h>