Nominate our 2022 Qt Champions!

I need help ; the connect() is not working.

  • Greetings from Nepal.

    We're building a desktop application using Qt Creator. In short, this application uses QTcpSocket and QTcpServer and the socket is multithreaded (using QThread) i.e. different users can connect at a time. MainWindow, MyServer and MyThread are different c++ class.

    When a "Host "push button is pressed (mainwindow.cpp), the server is started (myserver.cpp). When a user is connected to the server, the server starts new thread for the connected user (mythread.cpp). When the user sends char/string, the Qthread class receives the char/string. But we want to pass the string to MainWindow and display using QLineEdit. Todo so, we use a signals and slot but it's not working.

    // mainwindow.cpp
    myThread = new MyThread(); // MyThread is a c++ class
    void MainWindow::updateChat(QString str)


    void MyThread::readyRead()
      emit chatText(data);

  • Qt Champions 2017

    Can you confirm readyRead method is called ? Do you see any error like connect issue on application log window or logs ?

  • yeah, the readyRead() method is called when a user send something, qDebug()<<data; is showing the char/string. But mainwindow is not receiving the string.

    thank you for reply.

  • Thank you. I solved the problem.

Log in to reply