Binding Array value in to listview control in nokia Qt?

556 Views Asked by At

In my application i have to bind a list of array value in to list view control. so, I created like this and build successfully but it crash.

 QString array_List[5]={"Delphi","Mobile","Dot Net","Java","Open Source"};
    for(int i=0;i<5;i++)
        {
            list << array_List[i];
        }
    ui->list_View->setModel(new QStringListModel(list));
2

There are 2 best solutions below

4
On BEST ANSWER

The problem is your are going out of your array.

Replace

i<=5

with

i<5

I would prefer writing:

QStringList list;
list << "Delphi" << "Mobile" << "Dot Net" << "Java" << "Open Source";
ui->list_View->setModel(new QStringListModel(list));
0
On

You need i < 5 instead of i <= 5.