[Qt-interest] Passing QList<QStringList> as arguments
John Weeks
john at wavemetrics.com
Wed Aug 25 00:45:48 CEST 2010
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100824/d8ca03f6/attachment.html
More information about the Qt-interest-old
mailing list