[Qt-interest] Passing QList<QStringList> as arguments
Ellen Kestrel
dragonflykes at gmail.com
Wed Aug 25 01:11:49 CEST 2010
You can also cast the base class as a derived class in Qt with
qobject_cast<>(), though both classes have to inherit QObject for that to
work, and QLists don't inherit QObject, so.
On Tue, Aug 24, 2010 at 5:45 PM, John Weeks <john at wavemetrics.com> wrote:
>
> On Aug 24, 2010, at 2:50 PM, Eric Clark wrote:
>
> No because QStringList is not the same as QList<QString>. QStringList
> inherits QList<QString>, it is not a typedef. If a function expects a
> QStringList you need to use a QStringList because up-casting (if that is a
> word) is not valid in c++. You can, however, downcast a QStringList to a
> QList<QString> because it is a QList<QString>. Hope this makes sense, it did
> to me…
>
>
> I've always heard "down cast" as meaning getting a derived class pointer
> from a base class, and "up cast" as the opposite. But you don't hear "up
> cast" because a pointer to a derived class in C++ simply *is* a pointer to
> the base class, no cast required.
>
> C++ does have dynamic_cast<>() that allows you (if you have run-time type
> information enabled) to get a pointer to a derived class if you hold a
> pointer to the base class. You have to be ready for an exception to be
> thrown if the pointer you hold really isn't a pointer to the derived class,
> though.
>
> Regards, John Weeks
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100824/3c589e2f/attachment.html
More information about the Qt-interest-old
mailing list