1

I'd like to know how to create a simple ListView control with QT? I mean a table-like control that has multiple rows and columns, rows can be changed at runtime(edit/add/insert/remove row). I've been googling for a while, all the tutorials are about the three standard table-like controls: QListView, QTableView, QTreeView, but they seem to have limits

QListView: only one column QTableView: row/column count is fixed QTreeView: there is a expander in the first column 

I prefer to use MVC in my application for performance, so I'm using the Qxxx*View*, I'm new to QT, any suggestion? Thanks.

1
  • 1
    The number of rows and columns isn't fixed in QTableView. I don't see how it would pose limitations on your requirements. Commented Nov 12, 2013 at 15:59

1 Answer 1

2

in the past you could use addColumn() method:

 m_treeView = new QListView(); m_treeView->addColumn( "Tree" ); m_treeView->addColumn( "First" ); m_treeView->addColumn( "Second" ); m_treeView->addColumn( "Third" ); m_treeView->setRootIsDecorated( true ); QListViewItem *root = new QListViewItem( m_treeView, "root" ); QListViewItem *a = new QListViewItem( root, "A" ); new QListViewItem( a, "foo", "1", "2", "3" ); new QListViewItem( a, "bar", "i", "ii", "iii" ); 

http://www.digitalfanatics.org/projects/qt_tutorial/chapter13.html

however since Qt 4 it is not supported. Now list views are designed to view simple lists. You can use QTableView instead.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.