In English please... what is "of" for.
-
I am trying to find out what is "of" for in this connect.
Mrs Google is of ( no pun intended ) no use.connect(server, QOverload<const QString &>::of(&BT_ChatServer::clientConnected),
this, &BT_Connect::clientConnected);I believe this "connect" is between two objects and having a tough time to actually test the "connect" .
Sure would like to learn how to emulate events / signals. Relying on hardware expected responses is too tiring .... -
@AnneRanch said in In English please... what is "of" for.:
I am trying to find out what is "of" for in this connect.
connect( server, QOverload<const QString &>::of(&BT_ChatServer::clientConnected), this, &BT_Connect::clientConnected );QOverload<>::of() is a static function in the Overload helper class that selects one of many overloads for a signal (this case) or slot and returns the correct function pointer. In C++11 code you can use QOverload directly. In C++14 and later you can use the qOverload helper.
Selecting Overloaded Signals and Slots (Qt5)
Selecting Overloaded Signals and Slots (Qt6)I believe this "connect" is between two objects
All QObject::connect() calls connect two QObjects.
and having a tough time to actually test the "connect"
QObect::connect() returns a value that can be used to test if the act of making the connection was successful. This is especially useful when using the old-style, string-based connect() call, which would fail at run-time and emit a warning, but continue anyway.
New-style connect() will generally fail at compile time because the arguments are incorrect.Sure would like to learn how to emulate events / signals. Relying on hardware expected responses is too tiring ....
Create a QObject subclass that has a signal with the same signature as the genuine
serverobject and connect that in place ofserver. Every time the faked server emitsclientConnected()the client should react. Qt Test contains a range of classes for unit testing.