Search code examples
qtqt4

How can I solve the problem of (Incompatible sender/receiver arguments)?


Here is the code where I use CONNECT.I use it to go to the slot slotReadyRead where i can read the content the reply. But I have a message while debugging or running the program which is

QObject::connect: Incompatible sender/receiver arguments QNetworkReplyImpl::readyRead() --> MainWindow::slotReadyRead(QNetworkReply*)

.cpp

    void MainWindow::on_pushButton_clicked()
{
     QNetworkAccessManager* manager = new QNetworkAccessManager(this);
     QNetworkRequest request;
     request.setUrl(QUrl("http://lascivio.co/mobile/get.php?name=marwa"));
     QNetworkReply *reply = manager->get(request);
     connect(reply, SIGNAL(readyRead()), this, SLOT(slotReadyRead(QNetworkReply*)));
}
void MainWindow::slotReadyRead(QNetworkReply* reply)
{
    QByteArray b (reply->readAll());
    QString s(b);
    ui->lineEdit->setText(s);
}

.h

public slots:
    void slotReadyRead(QNetworkReply* reply);

Solution

  • The slot needs to have a signature compatible with the signal. So either define it as:

    void slotReadyRead();
    

    Or make the reply optional:

    void slotReadyRead(QNetworkReply* reply = null);