QDBusUnixFileDescriptor Class
The QDBusUnixFileDescriptor class holds one Unix file descriptor. More…
| Header | #include <QDBusUnixFileDescriptor> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::DBus) |
| Module | Nt D-Bus C++ Classes |
List of all members, including inherited members
Public Functions
| QDBusUnixFileDescriptor() | |
| QDBusUnixFileDescriptor(int fileDescriptor) | |
| QDBusUnixFileDescriptor(const QDBusUnixFileDescriptor &other) | |
| QDBusUnixFileDescriptor(QDBusUnixFileDescriptor &&other) | |
| QDBusUnixFileDescriptor & | operator=(const QDBusUnixFileDescriptor &other) |
| QDBusUnixFileDescriptor & | operator=(QDBusUnixFileDescriptor &&other) |
| ~QDBusUnixFileDescriptor() | |
| bool | isValid() const |
| int | fileDescriptor() const |
| void | setFileDescriptor(int fileDescriptor) |
| void | giveFileDescriptor(int fileDescriptor) |
| int | takeFileDescriptor() |
| void | swap(QDBusUnixFileDescriptor &other) |
Static Public Members
| bool | isSupported() |
Detailed Description
A file descriptor can travel in a message to a process on the same machine, if both ends of the connection support it; see QDBusConnection::connectionCapabilities(). The object owns the descriptor it holds and closes it when the last copy is destroyed:
QFile log("/var/log/app.log");
log.open(QIODevice::ReadOnly);
iface.call("Watch", QVariant::fromValue(QDBusUnixFileDescriptor(log.handle())));
See also QDBusConnection::connectionCapabilities().
Differences from Qt
None.
Member Function Documentation
QDBusUnixFileDescriptor::QDBusUnixFileDescriptor()
Constructs an object that holds no file descriptor.
QDBusUnixFileDescriptor::QDBusUnixFileDescriptor(int fileDescriptor)
Constructs an object that holds a duplicate of fileDescriptor. The caller keeps its own descriptor.
QDBusUnixFileDescriptor::QDBusUnixFileDescriptor(const QDBusUnixFileDescriptor &other)
Constructs a copy of other that shares its descriptor.
QDBusUnixFileDescriptor::QDBusUnixFileDescriptor(QDBusUnixFileDescriptor &&other)
Constructs an object that takes the descriptor of other.
QDBusUnixFileDescriptor::~QDBusUnixFileDescriptor()
Destroys the object. The descriptor is closed when the last object that shares it is destroyed.
int QDBusUnixFileDescriptor::fileDescriptor() const
Returns the descriptor, or -1 if there is none. The object still owns it.
void QDBusUnixFileDescriptor::giveFileDescriptor(int fileDescriptor)
Makes the object hold fileDescriptor itself, which it now owns and closes.
bool QDBusUnixFileDescriptor::isSupported()
Returns true if this system can pass file descriptors over D-Bus.
bool QDBusUnixFileDescriptor::isValid() const
Returns true if the object holds a file descriptor.
QDBusUnixFileDescriptor & QDBusUnixFileDescriptor::operator=(const QDBusUnixFileDescriptor &other)
Makes this object share the descriptor of other and returns a reference to it.
QDBusUnixFileDescriptor & QDBusUnixFileDescriptor::operator=(QDBusUnixFileDescriptor &&other)
Moves the descriptor of other into this object and returns a reference to it.
void QDBusUnixFileDescriptor::setFileDescriptor(int fileDescriptor)
Makes the object hold a duplicate of fileDescriptor, which the caller keeps.
void QDBusUnixFileDescriptor::swap(QDBusUnixFileDescriptor &other)
Swaps this object with other.
int QDBusUnixFileDescriptor::takeFileDescriptor()
Returns the descriptor and gives up ownership of it; the object no longer holds one. If other objects share it, the caller gets a duplicate.