QObject

So, what is this funky QObject thingy we are inheriting from which keeps popping up? Well, it’s the base class for all Qt objects, and it gives us some powerful features for free.

QObjects organize themselves into object hierarchies with a parent object assuming ownership of their child objects, which means we don’t have to worry (as much!) about memory management. For example, if we have an instance of a Client class derived from QObject that is the parent of an Address also derived from QObject, then the address is automatically destroyed when the client is destroyed.

QObjects carry metadata that allows a degree of type inspection and is the backbone for interaction with QML. They can also communicate with each other via an event ...

Get Learn Qt 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.