Important: Please read the Qt Code of Conduct -

"No such signal TcpServer" error in QObject::connect

  • Hello guys,

    I tried to script a tcp server and I've almost done it. But right now I'm getting an error in my console output which says:

    QObject::connect: No such signal QTcpServer::receiveRequest()
    Server started!

    And I don't know how to fix that. I hope you guys can help me with it. Thanks for all answers!
    Here is my code:

    #ifndef TCPSERVER_HPP
    #define TCPSERVER_HPP
    #include <QObject>
    #include <QTcpServer>
    #include <QTcpSocket>
    class TcpServer : public QObject
        explicit TcpServer(QObject *parent = nullptr);
    public slots:
        void receiveRequest();
        void sendData(long long);
        QTcpServer *server;
    #endif // TCPSERVER_HPP
    #include "TcpServer.hpp"
    #include "ServerUi.hpp"
    #include <QDebug>
    #include <string>
    #include <iostream>
    static QTcpSocket *socket;
    TcpServer::TcpServer(QObject *parent) : QObject(parent)
        server = new QTcpServer(this);
        connect(server, SIGNAL(receiveRequest()), this, SLOT(receiveRequest()));
        if(!server->listen(QHostAddress::Any, 1234))
            qDebug() << "Server could not start!";
            qDebug() << "Server started!";
    void TcpServer::receiveRequest()
        std::string receivedRequest;
        socket = server->nextPendingConnection();
        receivedRequest = socket->readAll().toStdString();
        if(receivedRequest == "get270value")
    void TcpServer::sendData(long long label270) {
        const char* convertedLabel = reinterpret_cast<char * const>(label270);

  • Moderators

    easy enough, connect your receiveRequest slot to an signal that actually exists in the QTcpServer - Class

    you have the following options:

    • acceptError(QAbstractSocket::SocketError socketError)
    • void newConnection()
    • void destroyed(QObject *obj = nullptr)
    • void objectNameChanged(const QString &objectName)

  • @J-Hilk said in "No such signal TcpServer" error in QObject::connect:


    It works, thank you very much!

Log in to reply