Important: Please read the Qt Code of Conduct -

Serial port reading with QSerialPort : No such slot QObject...

  • Hello everyone,

    I'm trying to read data sent on a serial port using the QSerialPort library. The data are values that come from an Arduino card. After some research, I did the following blockcode which sets the serial port to read and then a signal connected to a slot to acquire the data. The'PortListener' function is then called in the main.

    PortListener::PortListener(const QString &portName)
        this->port = new QSerialPort();
        connect(port, SIGNAL(readyRead()), this, SLOT(readyReadSlot()));
    void PortListener::readyReadSlot()
            QByteArray data = port->readAll();
            qDebug() << "message :" << data;

    After running the program, I get an error message like "QObject::connect: No such slot QObject::readyReadSlot()" which seems to mean that no data is sent on the serial port. However, I did some tests with the examples provided by the QextSerialPort library and I am receiving the data well so the error will not come from there. I would still like to use QSerialPort.

    Does anyone have any idea where the problem might come from?

  • Moderators

    hi @Quintinius said in Serial port reading with QSerialPort : No such slot QObject...:
    you're using the olf (Qt4) syntax,

    connect(port, SIGNAL(readyRead()), this, SLOT(readyReadSlot()));

    using that synatx, you must mark functions that are slots, with the slots macro in the header file. Or it won't work at all

    public slots:
         void readyReadSlot();

  • @Quintinius said in Serial port reading with QSerialPort : No such slot QObject...:

    "QObject::connect: No such slot QObject::readyReadSlot()"

    Error is saying that the class QObject has no method public slot called readyReadSlot

    I still don't know why you have this error, but please try to use the new Signal/Slot syntax

    connect(port, &QSerialPort::readyRead, this, &PortListener::readyReadSlot);

Log in to reply