Dear visitor, welcome to QtForum.org.
If this is your first visit here, please read the Help. It explains in detail how this page works.
To use all features of this page, you should consider registering.
Please use the registration form, to register here or read more information about the registration process.
If you are already registered, please login here.
Index out of Range
Hi Friends,
I am getting an error 'Index out of Range' in this program
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
QDir dir(ImagesDirPath);
dir.setFilter(QDir::Files | QDir::NoSymLinks);
QStringList filters;
filters << "*.xml";
dir.setNameFilters(filters);
dir.setSorting(QDir::Name);
QStringList Strlist;
QFileInfoList list = dir.entryInfoList();
for (int i = 0; i < list.size(); ++i)
{
QFileInfo fileInfo = list.at(i);
Strlist<<fileInfo.baseName();
}
ui.comboBox_2->insertItems(0,Strlist);
|
How to solve this?
Thanks in Advance..
Thanks and Regards.
V. Santhosh
santhoshv84,
|
Source code
|
1
2
3
4
5
6
|
QStringList strList;
foreach( QFileInfo fi, dir.entryInfoList() ){
if( !fi.baseName().isEmpty() ){
strList << fi.baseName();
}
}
|
Hope this helps.
Junior