Important: Please read the Qt Code of Conduct -

I get an error when refactoring connect.

  • Hi.
    I refactoring [connect]. Then, I get an error.


    connect(m_pUdpSockRecv, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(fnSocketError()));


    connect(m_pUdpSockRecv, &QAbstractSocket::error, this, &Udp::fnSocketError);

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

    Do I need to add anything?

  • Moderators

    @w-tkm what version of Qt do you use ?

    the error signal was deprecated and errorOccured was introduced.
    This was made due to the fact that error is not only a signal but also a regular function of QAbstractSocket.

    to use an overload in the new connect syntax requires the use of complicated casting, or the use of the qOverload macro

Log in to reply