Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

I get an error when refactoring connect.



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

    brefor:

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

    after:

    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
    https://doc.qt.io/qt-5/qtglobal.html#qOverload


Log in to reply