samedi 15 avril 2023

Why we need to use QOverload in connect two signal and slot?

I saw an example for running a TCP Server with Qt. In this example a class was created(class name is Client) and in constructor of this class there is 5 connection between signals and slots of QTcpSocket and Client class. In one of connection this code was writed: connect(&socket,QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::errorOccurred),this,&Client::error); I am familiar with signal and slot mechanism and how to connect. Now my questions are:
1-What is the role of "of" in above code?
2-According to that 'errorOccurred' signal exist in 'QAbstractSocket', why we use QOverload?
3-If it is possible some one explian part of QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::errorOccurred). This Part with this format is ambiguous for me. Thanks a lot.

Aucun commentaire:

Enregistrer un commentaire