IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

QObjectCleanupHandler Class

The QObjectCleanupHandler class watches the lifetime of multiple QObjects.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

QObjectCleanupHandler Class

  • Header: QObjectCleanupHandler

  • CMake:

    find_package(Qt6 REQUIRED COMPONENTS Core)

    target_link_libraries(mytarget PRIVATE Qt6::Core)

  • qmake: QT += core

  • Inherits: QObject

  • Group: QObjectCleanupHandler is part of objectmodel

Detailed Description

A QObjectCleanupHandler is useful whenever you need to know when a number of QObjects that are owned by someone else have been deleted. This is important, for example, when referencing memory in an application that has been allocated in a shared library.

To keep track of some QObjects, create a QObjectCleanupHandler, and add() the objects you are interested in. If you are no longer interested in tracking a particular object, use remove() to remove it from the cleanup handler. If an object being tracked by the cleanup handler gets deleted by someone else it will automatically be removed from the cleanup handler. You can delete all the objects in the cleanup handler with clear(), or by destroying the cleanup handler. isEmpty() returns true if the QObjectCleanupHandler has no objects to keep track of.

See Also

See also QPointer

Member Function Documentation

 

QObjectCleanupHandler::QObjectCleanupHandler()

Constructs an empty QObjectCleanupHandler.

[virtual] QObjectCleanupHandler::~QObjectCleanupHandler()

Destroys the cleanup handler. All objects in this cleanup handler will be deleted.

See Also

See also clear()

QObject *QObjectCleanupHandler::add(QObject *object)

Adds object to this cleanup handler and returns the pointer to the object.

See Also

See also remove()

void QObjectCleanupHandler::clear()

Deletes all objects in this cleanup handler. The cleanup handler becomes empty.

See Also

See also isEmpty()

bool QObjectCleanupHandler::isEmpty() const

Returns true if this cleanup handler is empty or if all objects in this cleanup handler have been destroyed; otherwise return false.

See Also

See also add(), remove(), clear()

void QObjectCleanupHandler::remove(QObject *object)

Removes the object from this cleanup handler. The object will not be destroyed.

See Also

See also add()

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+