[Qt-interest] QList<T> conversion

Thiago Macieira thiago at kde.org
Fri Jan 28 23:56:55 CET 2011


On Friday, 28 de January de 2011 19:58:12 Gustavo de Sá Carvalho Honorato 
wrote:
> Hi,
> 
> is it possible to convert QList<A*> to QList<QObject*>, where A inherits
> from QObject? I would like to do this without create a new QList<QObject*>
> container and typecasting each element before add into this new one. Is
> there any better solution than that?

Disclaimer: if you tell anyone I told you this, I'll deny any knowledge of the 
fact.

    QList<A *> list;
    QList<QObject *> objectList 
The data structures in QList<T*> are isomorphic for all T.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Senior Product Manager - Nokia, Qt Development Frameworks
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358


More information about the Qt-interest-old mailing list