tableView->sortByColumn(index.column());
void QAbstractItemModel::sort(int column, Qt::SortOrder order){ Q_UNUSED(column); Q_UNUSED(order); // do nothing}
while(row < model->rowCount()){for(;column<=93;column++){ QTableWidgetItem *wdgItem = new QTableWidgetItem(model->index(row,column).data().toString()); wdg->setItem(row,column,wdgItem);}column = 0;++row;}
wdgItem->setFlags(Qt::ItemIsUserCheckable);
QSqlQueryModel *model = new QSqlQueryModel;model->setQuery("SELECT name, salary FROM employee");model->setHeaderData(0, Qt::Horizontal, tr("Name"));model->setHeaderData(1, Qt::Horizontal, tr("Salary"));QTableView *view = new QTableView;view->setModel(model);view->show();
QSortFilterProxyModel sortingModel;sortingModel.setSourceModel(&model);view.setModel(&sortingModel);...view.horizontalHeader()->setSortIndicator(1, Qt::AscendingOrder);view.horizontalHeader()->setSortIndicatorShown(true);view.horizontalHeader()->setClickable(true);...