Reputation: 343
I have a signal coming from QTableWidget to slot where is the function recalculate(int, int)
. Based on the user input, the function does some calculations and changes the cell background color.
connect(ui->tableWidget_input, SIGNAL(cellChanged(int, int)), this, SLOT(recalculate(int, int)));
Problem is the cellChanged emits the signal when the background color is changed, I need the signal emission only when the text is changed.
The color change causes the infinite loop like this:
Recalculate
(): When a condition is passed, the background is changed.Recalculate
(): When a condition is passed, the background is changed.Please, do you have any idea how to do signal emission by the text change only - no background color change?
Upvotes: 1
Views: 210
Reputation: 243965
A simple solution is to block the emission of QTableWidget signals using blockSignals():
void Foo::recalculate(int row, int column){
ui->tableWidget_input->blockSignals(true);
// update here
ui->tableWidget_input->blockSignals(false);
}
Upvotes: 3