开发者

QListView not adding Items

I installed the Nokia Qt SDK and made a new project which involved a user interface.

Then I referred to a particular video, Creating interactive QT hello world GUI application using QT Creator.

Now I am not able to ad开发者_StackOverflow社区d items in list view as there is no function to do that.

Is there some other function to do it?


To add rows:

ui->listview->model()->insertRow ( int row)

or

ui->listview->model()->insertRows ( int row, int count)

Both methods return true if the rows were successfully inserted.

To set data (for each cell):

ui->listview->model()->setData(ui->listview->model()->index ( int row, int column),QVariant value);


What do you mean by "There is no function to do that" ?

Have you already looked into the Qt Documentation? There is also a QListWidget where you can directly add widgets. More useful is the QListView you mentioned, for which you should have a look at Qt Model/View Programming first.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜