[Interest] QPlugin and RTTI

Thiago Macieira thiago.macieira at intel.com
Mon Jun 23 18:06:54 CEST 2014


Em seg 23 jun 2014, às 12:08:05, Till Oliver Knoll escreveu:
> Am 23.06.2014 um 03:11 schrieb Thiago Macieira <thiago.macieira at intel.com>:
> > ... In QObject and qobject_cast's case, it's the
> > meta object (the output of moc); for RTTI and dynamic cast, it's the
> > typeinfo. Each must exist in a single library.
> 
> Not sure whether I fully understand your "[runtime info] must exist in a
> single library" requirement here, but I always thought that the advantage
> of using the "Qt Meta System" over the RTTI was that the former would work
> "across library boundaries", whereas the later not (guaranteed, since
> compiler-specific).

In all compilers that Qt supports, the requirement is the same: there is one 
structure that must be exported from a single library. For QObject, it's the 
meta object; for RTTI, it's the typeinfo.

The difference is *how* you accomplish that. It's a lot easier to get QObject 
right because of the requirement to run moc. But it's also possible to make a 
silly mistake and have the same problem of it not working across library 
boundaries. That silly mistake is naming the .h file where the base class is 
declared in the HEADERS of plugin or the application -- it needs to be *only* 
in the library.

But once you've got it working with QObject, RTTI will also work.
-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Interest mailing list