PDA

View Full Version : How to use QColumnView with QSqlTableModel



npascual
19th June 2013, 11:40
Hello, how I can use a QColumnView to display the items of a QSqlTableModel?

For example, if I define something like this code:


QSqlTableModel *model = new QSqlTableModel ;
model->setTable("dataBaseTable");
model->select();

QColumnView *view = new QColumnView;
view->setModel(model);

I obtain the elements of the first column of the dataBaseTable in the left column of the view, but when I click one element in the view, how I can to see more elements in the next column view?

Thanks

Santosh Reddy
20th June 2013, 15:52
I think you want to use QTableView instead of QColumnView.

What is that you want to do with QColumnView? It is normaly required for tree models not for table model.

npascual
21st June 2013, 08:37
I want to use QColumnView to show four nested lists of elements. I thought to use QSqlTableModel because I read this elements from a SQL table.