Run Time Type Identification

This allows you to determine at run the time the actual type of the object.

C++ has dynamic_cast and typid available. While Qt adds:

  1. qobject_cast
  2. QObject::inherits()

A typecast operator converts an expression from one type to another.


DestinationType* qobject_cast<DestinationType*> (QObject qObjectPointer);

You can only use qobject_cast with objects derived from QObject.

inherits() allows you to see whether a object inherits from another object for example:

// Returns a boolean
dog->inherits("Animal");

results matching ""

    No results matching ""