Connect: unresolved overloaded function type



  • Hello.
    I'm trying to connect QTcpSocket signal error to my slot in Qt5 style, but it doesn't compile, because QAbstractSocket, from which QTcpSocket inherits, also have error function (returns last error type), and seems that compile can't determinate which one to connect.
    My compiler is gcc 4.7.2 (can't use newer versions cause of rules).

    socket = new QTcpSocket(this);
    connect(socket, &QTcpSocket::error, this, &Network::socketErrorSlot);


  • Ok, i got it:

    // Disambiguate overloaded member function below with static cast
    connect(socket, static_cast<void (QTcpSocket::*) (QAbstractSocket::SocketError)>(&QTcpSocket::error), this, &Network::socketErrorSlot);
    

    I think that deserves to be in bugtracker, isn't it? Not good idea to implement new notation and use the same names for method and signal.



Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.