Search code examples
c++qtqapplication

QApplication without display


I using Qt3.3 and I'm trying to create an QApplication without display. I need to check signals from QSocket objects, and this is the reason that I need the QApplication.

I'm trying to do QApplication( 0, 0 ), but I'm getting "QApplication: invalid Display* argument.".

How is the correct way to do it?


Solution

  • From the docs:

    QApplication::QApplication ( int & argc, char ** argv, bool GUIenabled )

    Constructs an application object with argc command line arguments in argv. If GUIenabled is TRUE, a GUI application is constructed, otherwise a non-GUI (console) application is created.

    Set GUIenabled to FALSE for programs without a graphical user interface that should be able to run without a window system.

    You get that message because the compiler probably binds against this constructor method

    QApplication::QApplication(Display *dpy,HANDLE visual=0,HANDLE colormap=0)
    

    treating your first zero as a NULL pointer to Display * (I guess this is a Display structure you can get from X11)