Question

I create a new Read QSocketNotifier (QSocketNotifier::Read) and I install it on a QSslSocket. What is the QSslSocket signal that is emitted when activated signal is emitted from QSocketNotifier?

Is there any difference between the activated signal emitted by a QSocketNotifier which is installed on a QSslSocket and QIODevice::readyRead signal emitted by a QSslSocket?

Was it helpful?

Solution

If the QSocketNotifier is watching a QIODevice, then there is no functional difference between QIODevice::readyRead() and QSocketNotifier::activated(QSocketNotifier::Read). For that reason, you don't need a QSocketNotifier if you're only using QIODevice objects.

The main use of QSocketNotifier is to monitor a socket (or any other file descriptor) that you opened through a low-level API. You may pass it a file descriptor that is not associated to another QObject (such as a file opened through std::ifstream) and it will fire a activated() signal when you may read from your file descriptor, which is useful since a generic file descriptor won't fire Qt signals by itself.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top