I am using QListView to get a list with two items in each row,
like
Martin Luther
Dennis Ritchie
where each text is one column and should be able to sort using each of the string.
With the following code, i m getting only the second name. i want both the names to be visible.
ListView :: ListView (QMainWindow *mainWindow)
{
contactList = new QListView (mainWindow);
QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this);
model = new QStandardItemModel (this);
proxyModel->setDynamicSortFilter(true);
proxyModel->setSortCaseSensitivity(Qt::CaseSensitive);
proxyModel->setSourceModel(model);
contactList->setModel(proxyModel);
int row = model->rowCount(); /* +1 for a new row */
int col = 0;
model->setItem( row, col, new QStandardItem("Martin"));
model->setItem( row, col++, new QStandardItem("Luther"));
row = model->rowCount(); /* +1 for a new row */
col = 0;
model->setItem( row, col, new QStandardItem("Dennis"));
model->setItem( row, col++, new QStandardItem("Ritchie"));
proxyModel->setSortRole(0);
proxyModel->sort (0);
}
Can anybody help me get this working.??