[Qt-interest] Infinite loop with QHeaderView::sortIndicatorChanged
Sean Harmer
sean.harmer at maps-technology.com
Sun May 17 11:32:45 CEST 2009
On Saturday 16 May 2009 20:44:24 Stephen Collyer wrote:
> I'm trying to implement column sorting in a QTableView. I have
> code like so:
>
> connect(tx_table_view_->horizontalHeader(), SIGNAL(
> sortIndicatorChanged(int, Qt::SortOrder) ),
> this, SLOT( sort_by_column(int, Qt::SortOrder) )
> );
>
> ...
>
> void MDPMainWindow::sort_by_column(int logicalIndex, Qt::SortOrder order)
> {
> tx_table_view_->sortByColumn(logicalIndex, order);
> }
>
> where sort_by_column is a slot in the current class, and tx_table_view_
> is a QTableView*.
>
> When I click on a sort indicator in the header, sort_by_column(..) is
> called in some kind of infinite loop until the app dumps core. I guess the
> call to QTableView::sortByColumn is causing the signal to be reemitted for
> some reason, but I can't see why.
>
> Can someone explain what I'm doing wrong here ?
Can't you simply call QTableView::setSortingEnabled( true ) when you
initialise your view and let the default implementation handle everything for
you?
Sean
More information about the Qt-interest-old
mailing list