You are not logged in.

santhoshv84

Beginner

  • "santhoshv84" is male
  • "santhoshv84" started this thread

Posts: 28

Location: Chennai

Occupation: Programmer

  • Send private message

1

Tuesday, August 19th 2008, 10:55am

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

Junior

Professional

  • "Junior" is male

Posts: 1,613

Location: San Antonio, TX USA

Occupation: Senior Secure Systems Engineer

  • Send private message

2

Tuesday, August 19th 2008, 6:24pm

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