Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTcpService based server-clint
Qt 6.11 is out! See what's new in the release blog

QTcpService based server-clint

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 964 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Aijaz
    wrote on last edited by
    #1

    I recently started to work with qt creator and i got stuck the some error which i don't know why i am getting.
    I the following line of code i am trying to connect a virtual client to the server by using the (IP address - 127.0.0.1), but when i click on connect button it shows the error "qt.core.qobject.connect: QObject::connect: No such signal QTcpSocket::error(QAbstractSocket::SocketError)" and "
    qt.core.qobject.connect: QObject::connect: (receiver name: 'Dialog')".

    If anyone have any solution or suggestion please let me know.

    Code lines -
    void Dialog::on_pushButtonConnect_clicked()
    {
    m_pClientsocket->connectToHost(ui->textEditIP->toPlainText(),quint16(ui->textEditPort->toPlainText().toInt()) );
    connect(m_pClientsocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayError(QAbstractSocket::SocketError)));

    }

    jsulmJ 1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by Christian Ehrlicher
      #2

      Since you use Qt6 (I guess, you did not menion) I would say it's correct - there is no such a signal (anymore): https://doc.qt.io/qt-6/qabstractsocket.html#signals

      Please use the new signal/slot syntax to catch such errors on compile time.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      A 1 Reply Last reply
      4
      • A Aijaz

        I recently started to work with qt creator and i got stuck the some error which i don't know why i am getting.
        I the following line of code i am trying to connect a virtual client to the server by using the (IP address - 127.0.0.1), but when i click on connect button it shows the error "qt.core.qobject.connect: QObject::connect: No such signal QTcpSocket::error(QAbstractSocket::SocketError)" and "
        qt.core.qobject.connect: QObject::connect: (receiver name: 'Dialog')".

        If anyone have any solution or suggestion please let me know.

        Code lines -
        void Dialog::on_pushButtonConnect_clicked()
        {
        m_pClientsocket->connectToHost(ui->textEditIP->toPlainText(),quint16(ui->textEditPort->toPlainText().toInt()) );
        connect(m_pClientsocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayError(QAbstractSocket::SocketError)));

        }

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by jsulm
        #3

        @Aijaz error() is not a signal.
        What you want is: https://doc.qt.io/qt-5/qabstractsocket.html#errorOccurred

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        3
        • Christian EhrlicherC Christian Ehrlicher

          Since you use Qt6 (I guess, you did not menion) I would say it's correct - there is no such a signal (anymore): https://doc.qt.io/qt-6/qabstractsocket.html#signals

          Please use the new signal/slot syntax to catch such errors on compile time.

          A Offline
          A Offline
          Aijaz
          wrote on last edited by
          #4

          @Christian-Ehrlicher thanks for the suggestion, i will definitely try do d that.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Aijaz
            wrote on last edited by
            #5

            From the above suggestion i understood that there will be a change in syntax, but i exactly don't know what changes i should i make.
            Bellow is the change in code i tried to do,

            void Dialog::on_pushButtonConnect_clicked()
            {
            m_pClientsocket->connectToHost(ui->textEditIP->toPlainText(),quint16(ui->textEditPort->toPlainText().toInt()) );

            connect(ui->m_pClientsocket, &error::SocketError, ui->this, &displayError::SocketError);
            }
            (And now i am even getting even more error's)

            can anyone suggest me the correct way to do it.

            JonBJ 1 Reply Last reply
            0
            • A Aijaz

              From the above suggestion i understood that there will be a change in syntax, but i exactly don't know what changes i should i make.
              Bellow is the change in code i tried to do,

              void Dialog::on_pushButtonConnect_clicked()
              {
              m_pClientsocket->connectToHost(ui->textEditIP->toPlainText(),quint16(ui->textEditPort->toPlainText().toInt()) );

              connect(ui->m_pClientsocket, &error::SocketError, ui->this, &displayError::SocketError);
              }
              (And now i am even getting even more error's)

              can anyone suggest me the correct way to do it.

              JonBJ Online
              JonBJ Online
              JonB
              wrote on last edited by
              #6

              @Aijaz said in QTcpService based server-clint:

              connect(ui->m_pClientsocket, &error::SocketError, ui->this, &displayError::SocketError);

              For syntax please read New Signal Slot Syntax.
              Probably more like

              connect(ui->m_pClientsocket, &QAbstractSocket:::errorOccurred, this, &Dialog:::displayError);
              
              1 Reply Last reply
              2

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved