[Qt-interest] Infinite loop with QHeaderView::sortIndicatorChanged

Stephen Collyer scollyer at netspinner.co.uk
Sat May 16 21:44:24 CEST 2009


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 ?

-- 
Stephen Collyer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090516/a7820def/attachment.html 


More information about the Qt-interest-old mailing list