[Development] Applications using -fno-rtti

Thiago Macieira thiago.macieira at intel.com
Mon Jun 22 17:21:43 CEST 2020

On Monday, 22 June 2020 00:22:33 PDT Eike Ziller wrote:
> dynamic_cast would be most useful if you could avoid using Q_OBJECT (and
> deriving from QObject) just for the purpose of casting. If you use Q_OBJECT
> throughout your class hierarchy, qobject_cast is available anyhow. So, the
> argument that Q_OBJECT makes it safe to use dynamic_cast reads a bit
> strange.

It's a circular argument: Q_OBJECT makes for a safe cast because it does the 
thing that makes cast safe. But if you can do the right thing, then you don't 
need Q_OBJECT.

Admittedly, it's easier to get Q_OBJECT right, because of the need for moc. 
Running moc on another library's headers is a big indication that something is 
wrong. But I've seen it.

Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel System Software Products

More information about the Development mailing list