Accessing C++ QLists from QML
Alternatively, You can use QVariantList (QList<QVariant>), it will automatically change to JavaScript array when passed to QML, and it is read and write-able from C++ and QML
Alternatively, You can use QVariantList (QList<QVariant>), it will automatically change to JavaScript array when passed to QML, and it is read and write-able from C++ and QML
You could use the following code: QList<int> list = QList<int>() << 1 << 1; or initializer list with C++11: QList<int> list({1, 1}); You can enable the latter with the -std=c++0x or -std=c++11 option for gcc. You will also need the relevant Qt version for that where initializer list support has been added to the QList … Read more
You should better use iterators for that: // Remove all odd numbers from a QList<int> QMutableListIterator<int> i(list); while (i.hasNext()) { if (i.next() % 2 != 0) i.remove(); }