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. New signal slot syntax

New signal slot syntax

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 4 Posters 606 Views 2 Watching
  • 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.
  • K Offline
    K Offline
    kaivolde
    wrote on last edited by
    #1

    Hi there,

    I have a problem converting this statement:

    connect( client, SIGNAL(error(QAbstractSocket::SocketError)),
                this, SLOT(onClientError(QAbstractSocket::SocketError)) );
    

    to the new syntax. 'client' is a QTcpSocket.

    I tried something like:

    connect( client, &QTcpSocket::error,
                 this, &MyServer::onClientError );
    

    but I get an error: no matching member function for call to 'connect'

    Can somebody help? Many thanks in advance.
    Kai

    aha_1980A 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      IIRC, QTcpSocket has two methods named error. You need to use qOverload to select the correct version.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      4
      • K kaivolde

        Hi there,

        I have a problem converting this statement:

        connect( client, SIGNAL(error(QAbstractSocket::SocketError)),
                    this, SLOT(onClientError(QAbstractSocket::SocketError)) );
        

        to the new syntax. 'client' is a QTcpSocket.

        I tried something like:

        connect( client, &QTcpSocket::error,
                     this, &MyServer::onClientError );
        

        but I get an error: no matching member function for call to 'connect'

        Can somebody help? Many thanks in advance.
        Kai

        aha_1980A Offline
        aha_1980A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @kaivolde

        And to add to @SGaist, the error() documentation describes how to do it.

        Qt has to stay free or it will die.

        1 Reply Last reply
        5
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi
          Just as a note.
          Often docs has sample when qOverload is needed
          http://doc.qt.io/qt-5/qabstractsocket.html#error-1

          1 Reply Last reply
          5
          • K Offline
            K Offline
            kaivolde
            wrote on last edited by
            #5

            Wow, amazing speed and everything 100% correct.
            Thanks to all of you!

            1 Reply Last reply
            0

            • Login

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