Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Connect: unresolved overloaded function type

    General and Desktop
    qt5 qabstractsocket qnetwork signal & slot compile-errors qtcpsocket
    1
    2
    3058
    Loading More Posts
    • 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.
    • UndeadBlow
      UndeadBlow last edited by UndeadBlow

      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);
      1 Reply Last reply Reply Quote 0
      • UndeadBlow
        UndeadBlow last edited by UndeadBlow

        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.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post