Connection Class

class QMetaObject::Connection

Public Functions

Connection(Connection &&o)
Connection(const Connection &other)
Connection &operator=(Connection &&other)
Connection &operator=(const Connection &other)
void swap(Connection &other)
bool operator bool() const

Detailed Description

Represents a handle to a signal-slot (or signal-functor) connection.

It can be used to check if the connection is valid and to disconnect it using QObject::disconnect(). For a signal-functor connection without a context object, it is the only way to selectively disconnect that connection.

As Connection is just a handle, the underlying signal-slot connection is unaffected when Connection is destroyed or reassigned.

Member Function Documentation

Connection::Connection(Connection &&o)

Move-constructs a Connection instance, making it point to the same object that o was pointing to.

Connection::Connection(const Connection &other)

Create a copy of the handle to the other connection


Creates a Connection instance.

Connection &Connection::operator=(Connection &&other)

Move-assigns other to this object, and returns a reference.

Connection &Connection::operator=(const Connection &other)

Assigns other to this connection and returns a reference to this connection.


Destructor for QMetaObject::Connection.

[since 5.15] void Connection::swap(Connection &other)

Swaps this Connection instance with other. This operation is very fast and never fails.

This function was introduced in Qt 5.15.

bool Connection::operator bool() const

Returns true if the connection is valid.

The connection is valid if the call to QObject::connect succeeded. The connection is invalid if QObject::connect was not able to find the signal or the slot, or if the arguments do not match.

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.