Imagine, that we have DataType class.
QVector - array of objects, such as:
// QVector<DataType> internal structure
DataType* pArray = new DataType[100];
QList - array of pointers to objects, such as:
// QList<DataType> internal structure
DataType** pPointersArray = new DataType*[100];
Therefore, direct access by index will be faster for QVector:
{
// ...
cout << pArray[index]; //fast
cout << *pPointersArray[index]; //slow, need additional operation for dereferencing
// ...
}
But swaping will be faster for QList, if sizeof(DataType) > sizeof(DataType*):
{
// QVector swaping
DataType copy = pArray[index];
pArray[index] = pArray[index + 1];
pArray[index + 1] = copy; // copy object
// QList swaping
DataType* pCopy = pPointersArray [index];
pPointersArray[index] = pPointersArray [index + 1];
pPointersArray[index + 1] = pCopy; // copy pointer
// ...
}
So, if you need direct access without swaping operations between elements (such as sorting, for example), or sizeof(DataType) <= sizeof(DataType*), your better way is use QVector. In other case use QList.