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. no matching function for call to 'of'

no matching function for call to 'of'

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 3 Posters 1.0k Views 1 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.
  • 6 Offline
    6 Offline
    63350541
    wrote on last edited by
    #1

    I'm trying to run the official QT chat example from GitHub
    but while opening the client in constructor I see an error no matching function for call to 'of'

    ChatClient::ChatClient(QObject *parent)
        : QObject(parent)
        , m_clientSocket(new QTcpSocket(this))
        , m_loggedIn(false)
    {
      ...
        // Forward the error signal, QOverload is necessary as error() is overloaded, see the Qt docs
        connect(m_clientSocket, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error), this, &ChatClient::error);
      ...
    }
    

    I simply fixed this by replacing

    QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error)
    

    with

    &QAbstractSocket::error
    

    on build I see
    9.png

    The same error no matching function for call to 'of' is on the server side too

    ServerWorker::ServerWorker(QObject *parent)
        : QObject(parent)
        , m_serverSocket(new QTcpSocket(this))
    {
    ....
        connect(m_serverSocket, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error), this, &ServerWorker::error);
    }
    

    and after the same fix I see a warning QAbstractSocket::error is not a signal [clazy-connect-non-signal]

    How to make this project work?

    J.HilkJ Pl45m4P 2 Replies Last reply
    0
    • 6 63350541

      I'm trying to run the official QT chat example from GitHub
      but while opening the client in constructor I see an error no matching function for call to 'of'

      ChatClient::ChatClient(QObject *parent)
          : QObject(parent)
          , m_clientSocket(new QTcpSocket(this))
          , m_loggedIn(false)
      {
        ...
          // Forward the error signal, QOverload is necessary as error() is overloaded, see the Qt docs
          connect(m_clientSocket, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error), this, &ChatClient::error);
        ...
      }
      

      I simply fixed this by replacing

      QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error)
      

      with

      &QAbstractSocket::error
      

      on build I see
      9.png

      The same error no matching function for call to 'of' is on the server side too

      ServerWorker::ServerWorker(QObject *parent)
          : QObject(parent)
          , m_serverSocket(new QTcpSocket(this))
      {
      ....
          connect(m_serverSocket, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error), this, &ServerWorker::error);
      }
      

      and after the same fix I see a warning QAbstractSocket::error is not a signal [clazy-connect-non-signal]

      How to make this project work?

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @63350541 said in no matching function for call to 'of':

      SocketError

      you're probably using Qt 5.15 ?

      than use:
      connect(m_clientSocket, &QAbstractSocket:: errorOccurred, this, &ChatClient::error);


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      4
      • 6 63350541

        I'm trying to run the official QT chat example from GitHub
        but while opening the client in constructor I see an error no matching function for call to 'of'

        ChatClient::ChatClient(QObject *parent)
            : QObject(parent)
            , m_clientSocket(new QTcpSocket(this))
            , m_loggedIn(false)
        {
          ...
            // Forward the error signal, QOverload is necessary as error() is overloaded, see the Qt docs
            connect(m_clientSocket, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error), this, &ChatClient::error);
          ...
        }
        

        I simply fixed this by replacing

        QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error)
        

        with

        &QAbstractSocket::error
        

        on build I see
        9.png

        The same error no matching function for call to 'of' is on the server side too

        ServerWorker::ServerWorker(QObject *parent)
            : QObject(parent)
            , m_serverSocket(new QTcpSocket(this))
        {
        ....
            connect(m_serverSocket, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error), this, &ServerWorker::error);
        }
        

        and after the same fix I see a warning QAbstractSocket::error is not a signal [clazy-connect-non-signal]

        How to make this project work?

        Pl45m4P Offline
        Pl45m4P Offline
        Pl45m4
        wrote on last edited by
        #3

        @63350541 said in no matching function for call to 'of':

        run the official QT chat example

        This doesn't look like an offcial Qt example.

        Official chat examples can be found here

        • https://doc.qt.io/qt-5/qtnetwork-network-chat-example.html
          or here
        • https://doc.qt.io/qt-5/qtwebsockets-simplechat-example.html

        on build I see

        The same error no matching function for call to 'of' is on the server side too

        The message already tells you what went wrong.
        Look at QAbstractSocket::error if you are using a Qt Version < 5.15 or simply follow what @J-Hilk suggested if you have 5.15


        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

        ~E. W. Dijkstra

        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