Если вы счастливый пользователь Qt 5, то спокойно используйте STL алгоритмы с Qt контейнерами.
Historically, Qt used to provide functions which were direct equivalents of many STL algorithmic functions. Starting with Qt 5.0, you are instead encouraged to use directly the implementations available in the STL; most of the Qt ones have been deprecated (although they are still available to keep the old code compiling).
А иначе, если у вас тоже Qt 4-ой версии, невинное копирование приводит вас к злобнуму SegFault:
1 2 3 |
QList<int> src = QList<int>() << 1 << 3 << 5 << 7 << 8; QList<int> dest; std::copy( src.begin(), src.begin() + 1, dest.begin() ); |
Но, как известно, если очень хочется, то можно:
1 |
std::copy( src.begin(), src.begin() + 1, std::back_inserter(dest) ); |