2

I've created a little class to set some global shortcuts. But now, when i compile my app i see many errors:

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)
                                    ^

When i commented my class errors are gone. Here is it: http://pastebin.com/k5qSvqDn

Ok, i inherited class from QWidget instead of QMainWindow (i dont know why :D) and now i have another errors:

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()'

In my .pro file i've added LIBS += -lX11, it didnt helped.

So, what is the problem?

Efog
  • 1,155
  • 1
  • 15
  • 33
  • Try reordering your `#include` directives. Put any X11-related header *last* in your source file. The error is that some X11 header is adding a `#define None`, destroying the parsing for any subsequent header. – peppe Feb 02 '15 at 00:38

2 Answers2

3

I have not checked, but I believe you only missed adding the following to your .pro file, as stated at the docs

QT += gui x11extras

It's likely that that you may be missing a header file, but without the error message, I find it a bit hard to figure it out since I've never touched X11 stuff directly.

Hope it helps.

  • I am getting the error that `:-1: error: Unknown module(s) in QT: x11extras` Any idea how to remove this error? – arqam Aug 14 '17 at 09:40
2

Vinicius is close to having the full answer.

This is for Qt 5.1 or newer. The issue is that access to X11 and GDI handles were removed and then put back again in a slightly different place.

Add x11extras to the .pro file:

QT += gui x11extras

If the moc generated code fails to compile add the following to the bottom of the the file it includes (X11 headers define Bool):

#undef Bool

Add the following to the file that needs access to QX11Info:

#include <QtX11Extras/qx11info_x11.h>
Damian Dixon
  • 889
  • 8
  • 21