[ACCEPTED]-Casting a list as QVariant or QVariant List-qvariant
Accepted answer
I've had to do this several times, and to 9 my knowledge the only way is to create a 8 new list.
If this is something you have to 7 do frequently with varying types of lists 6 you could do something a little fancier:
template <typename T>
QVariantList toVariantList( const QList<T> &list )
{
QVariantList newList;
foreach( const T &item, list )
newList << item;
return newList;
}
so 5 that when you call your function that takes 4 in the QVariant list, you can just call
myFunction( toVariantList(myList) );
Note 3 that the given function will only work for 2 types that can be implicitly converted to 1 QVariants.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.