[Qt-interest] Infinite loop with QHeaderView::sortIndicatorChanged
Malyushytsky, Alex
alex at wai.com
Sun May 17 22:58:02 CEST 2009
I have not test it, but I think sortByColumn(logicalIndex, order); changes sortIndicator.
Try to change MDPMainWindow::sort_by_column, so it does not call iself, something like this:
void MDPMainWindow::sort_by_column(int logicalIndex, Qt::SortOrder order)
{
disconnect(tx_table_view_->horizontalHeader(), SIGNAL( sortIndicatorChanged(int, Qt::SortOrder) ),
this, SLOT( sort_by_column(int, Qt::SortOrder) ) );
tx_table_view_->sortByColumn(logicalIndex, order);
connect(tx_table_view_->horizontalHeader(), SIGNAL( sortIndicatorChanged(int, Qt::SortOrder) ),
this, SLOT( sort_by_column(int, Qt::SortOrder) ) );
}
Regards,
Alex
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Stephen Collyer
Sent: Saturday, May 16, 2009 12:44 PM
To: qtInterest
Subject: [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
---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.
“This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you.”
“Please consider our environment before printing this email.”
More information about the Qt-interest-old
mailing list