tableView->sortByColumn(i);
begin = ("CREATE TEMPORARY TABLE " + agency + " ENGINE=MyISAM SELECT g.agency_name, f.flats_date, r.room_cod, k.sale_name.............................
modelQuery->setQuery(begin);
QHeaderView * horizontalHeader () const;QHeaderView * verticalHeader () const;
class MyModel : public QSqlQueryModel {public: virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) { setQuery(QString("select * from mytable order by %1 %2").arg(column+1).arg(order == Qt::AscendingOrder?"asc":"desc")); }};class MyTable : public QTableView {public: MyTable() { setModel(new MyModel); sortByColumn(0); connect(horizontalHeader(), SIGNAL(sectionClicked(int)), this, SLOT(sortByColumn(int))); horizontalHeader()->setSortIndicatorShown(true); }};
QHeaderView * horizontalHeader () const; QHeaderView * verticalHeader () const;
QHeaderView *pH = tableWidget->horizontalHeader(); connect((QObject*)pH, SIGNAL(sectionClicked (int)), this, SLOT(sortedBy(int)));