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

Andreas Diehl Andreas_Diehl at abs.org
Mon May 18 08:53:31 CEST 2009


Hello Stephen.

The only place where the Signal would be re-emitted is in the
sortByColumn() method of QTableView. I didn't find any doc on this, but
perhaps sortByColumn automatically notifies the QHeaderView that that it
should change it's sort indicator after sorting a column.
Try connecting another signal like 'sectionClicked(int)' (from
QHeaderView) for testing. I think this would be a solution for your
infinite loop although I agree that the sortIndicatorChanged() signal
would be nicer because of the additional SortOrder parameter. 

Hope it helps,
	Andreas

________________________________

	Von: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] Im Auftrag von Stephen
Collyer
	Gesendet: Samstag, 16. Mai 2009 21:44
	An: qtInterest
	Betreff: [Qt-interest] Infinite loop with
QHeaderView::sortIndicatorChanged
	
	
	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
--
Mit freundlichen Gru?en
Andreas Diehl 
 
-------------------------- ABS -------------------------
ABS Systemberatung OHG          Tel: +49 (0)7053/9290-03
Hauffstr. 9                     Fax: +49 (0)7053/9290-
D-75385 Bad Teinach-Zavelstein        http://www.abs.org
Registergericht Calw HRA 1031
[mailto:Andreas_Diehl at abs.org]
 
----- Loesungen fuer den Maschinen- und Anlagenbau -----



More information about the Qt-interest-old mailing list