开发者

Binding Array value in to listview control in nokia Qt?

In my application i have to bind a list of array value in to list view control. so, I created like this and b开发者_运维知识库uild 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));


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));


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜