Guido Seifert schreef op 25-11-2013 17:00: > Hi, > I have here a strange effect and I wonder if this is the correct behaviour. > > I have a QVariantList x. > I add a few values > x << <int> > x << <QString> > x << <bool> > > Now I create a second QVariantList y and add a few values: > y << 1.5 > y << 3.5 > > And add the list y to x: > x << y > > Now I would expect that x has: > One int, one QString, one bool and one QVariantList with two doubles. > Actually I get one int, one QString, one bool, and two doubles. > > Instead of four my x list has five values. The second QVariantList gets > 'flattened'. > > Is this to be expected? Yes, it is.
Note that QVariantList is simply a QList<QVariant>. You adding a QVariantList to another QVariantList perfectly fits the function signature of QList::append(const QList<T>& value). In order to make it resolve to QList::append(const T& value), your QVariantList would first have to be implicitly casted to a QVariant to fit the signature. AFAIK, C++ will always prefer not to do an implicit cast if that isn't needed to resolve the function call. André _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest