Important: Please read the Qt Code of Conduct -

using connect() for socket in a class that inherits QObject

  • Hello, I'm working on an app that connects to a Unix Domain Socket as a client. The object that contains the socket is derived from a QObject. Because my object is a client, I would like to use the connect() call to connect to my IPC Server, however the program fails to compile, as it believes that I am attempting to use the QObject::connect() function to connect a signal and slot.

        if(connect(m_s1, (struct sockaddr *)&remote, len) == -1){
            perror("cannot connect");

    always fails with: /home/tom/Qt5.7.1/5.7/gcc_64/include/QtCore/qobject.h:251: error: invalid use of incomplete type ‘struct QtPrivate::QEnableIf<false, QMetaObject::Connection>’

    How can I go about using connect() to connect to a server? Thank you in advance

  • Lifetime Qt Champion


    Use ::connect. Doing so will start the name resolution in the global namespace which will find the method before the ones from QObject.

  • excellent, thanks!

Log in to reply