Hi ,
Am using Qtableview with QsqlTableModel for populating a table data. I want to sort the column based on user selection on column header.
i tried the way mentioned in http://stackoverflow.com/questions/3081340/qtableview-sorting-signal for getting the signal. (get the horizontal header from QtableView and connect signal sectionclicked(int logical index)
But the same signal is not getting emitted when i click on column header.
please find the code where connection is done
member variable
QHeaderView *m_horiz_header;
.cpp file
m_sqltablemodel->setTable(tabel_name);
m_sqltablemodel->setEditStrategy(QSqlTableModel::OnManualSubmit);
m_sqltablemodel->select();
m_horiz_header= m_table_view->horizontalHeader();
connect(m_horiz_header, SIGNAL(sectionClicked ( int logicalIndex ) ),
this, SLOT(on_sectionClicked ( int logicalIndex ) ));
slot function for sorting
void class::on_sectionClicked ( int logicalIndex ) {
m_horiz_header->setSortIndicator(logicalIndex, Qt::AscendingOrder);
m_table_view->sortByColumn(logicalIndex);
}
This function is not getting called, when column header is clicked.
Can you please help me how to do this, where i went wrong?
Thanks in advance.