QListView how to add column?
Solution 1
You cannot add a column, cause list views are designed to view simple lists. You need QTable[View/Widget].
Solution 2
QListWidget
is a single column only. Use QTreeWidget/View
for multiple columns.
Solution 3
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)
.
Samir
C/C++, .NET 2.0 (C++/CLI, C#), Install Shield Premier 2009, Qt......
Updated on July 22, 2022Comments
-
Samir almost 2 years
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 ?
-
Maxim Popravko about 14 yearsIt 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.