views:

502

answers:

2

How can I add columns to QListView control. Found a method addColumn while seardhing, but in my Qt Creator 1.2.1 based on Qt 4.5.2(32 bit) QListView doesn't have such method at all !!!

So how would I add columns ?

Say I have 3 columns then what is the code to add a row ?

+1  A: 

You cannot add a column, cause list views are designed to view simple lists. You need QTable[View/Widget].

Max
A: 

Hello.

As the start point you could watch how works QTableView class here: http://qt.nokia.com/doc/4.2/sql-tablemodel.html and do the similar things with QListView. So, you can't just emit addColumn() for QListView class, first you need to create model and then do listView->setModel(model).

Good luck.

mosg
It will not work due to QListView realization. It accept multicolumn models, but show only one of these. When you connect such model, you should set setModelColumn(index) to specify one the list will show.
Max