Home · All Classes · Main Classes · Grouped Classes · Modules · Functions |
The QSocketNotifier class provides support for monitoring activity on a file descriptor. More...
#include <QSocketNotifier>
Inherits QObject.
The QSocketNotifier class provides support for monitoring activity on a file descriptor.
The QSocketNotifier makes it possible to integrate Qt's event loop with other event loops based on file descriptors. For example, the QtCorba Solution uses it to process CORBA events. File descriptor action is detected in Qt's main event loop (QCoreApplication::exec()).
Once you have opened a device using a low-level (usually platform-specific) API, you can create a socket notifier to monitor the file descriptor. You can then connect the activated() signal to the slot you want to be called whenever an event occurs.
Although the class is called QSocketNotifier, it is normally used for other types of devices than sockets. QTcpSocket and QUdpSocket provide notification through signals, so there is normally no need to use a QSocketNotifier on them.
There are three types of socket notifiers: read, write, and exception. You must specify one of these in the constructor.
The type specifies when the activated() signal is to be emitted:
If you need to monitor both reads and writes for the same file descriptor, you must create two socket notifiers.
See also QFile, QProcess, QTcpSocket, and QUdpSocket.
The socket notifier can be used to inform the application of the following types of event:
Constant | Value | Description |
---|---|---|
QSocketNotifier::Read | 0 | There is incoming data. |
QSocketNotifier::Write | 1 | Data can be written. |
QSocketNotifier::Exception | 2 | An exception has occurred. |
Constructs a socket notifier with the given parent. It enables the socket, and watches for events of the given type.
It is generally advisable to explicitly enable or disable the socket notifier, especially for write notifiers.
See also setEnabled() and isEnabled().
Destroys the socket notifier.
This signal is emitted under certain conditions specified by the notifier type():
The socket is the socket identifier.
Returns true if the notifier is enabled; otherwise returns false.
See also setEnabled().
If enable is true, the notifier is enabled; otherwise the notifier is disabled.
The notifier is enabled by default.
If the notifier is enabled, it emits the activated() signal whenever a socket event corresponding to its type occurs. If it is disabled, it ignores socket events (the same effect as not creating the socket notifier).
Write notifiers should normally be disabled immediately after the activated() signal has been emitted; see discussion of write notifiers in the class description above.
See also isEnabled() and activated().
Returns the socket identifier specified to the constructor.
See also type().
Returns the socket event type specified to the constructor.
See also socket().
Copyright © 2005 Trolltech | Trademarks | Qt 4.1.0 |