Lets assume I have:
QList<QString> filenameList;
filenameList has the paths to some files.
Then I create a QFileInfoList
QFileInfoList fileInfoList;
How can I use .setFile method for every object in the fileInfoList? I tried:
for(int i=0;i<filenameList.length();i++)
{
fileInfoList[i].setFile(filenameList[i]);
}
But I get this error after trying the program(it compiles succesfully).
ASSERT failure in QList<T>::at: "index out of range"
Can someone help me?
fileInfoList is empty when you try to access the first element of the list. What you want to do is replace the call to setFile with
fileInfoList.append(QFileInfo(filenameList[i]));