Qt World Summit: Register Today!

[Solved] how to use the connectToHostImplementation function in QAbstractSocket

  • Hi!

    I'm trying to write a class that inherits from QAbstractSocket, but instead of using sockets it will use other means for communication. When reading the API reference I found that there is a slot called connectToHostImplementation(), which can be used for altering the behavior of connectToHost().

    How should I use this signal? Should I connect some signal to this slot?

  • No. You don't need to connect a signal to this slot. The virtual slot connectToHostImplementation() is called from connectToHost().

    Rationale is, that connectToHost() is not a virtual method and thus cannot be overridden in subclasses. All it does is to call connectToHostImplementation(), which is virtual (by means of C++ and by using QMetaObject::invokeMethod).

  • Noticed that I had accidently overloaded connectToHostImplementation instead of overriding it.
    Thanks for the help, now it works :)

Log in to reply