[Qt-interest] Is there a better way to code this to prevent recursive calling?
Knapp
magick.crow at gmail.com
Mon Feb 23 14:13:22 CET 2009
This code can be entered at ether point by changing a spinBox for each
value, HT or FP. I am still at the learning stages of both C++ and QT.
I was hoping that someone could suggest a more concise or readable bit
of code. The best way would be if label_HT could change the FP spin
box without causing it to call itself. It seems that setValue is just
like clicking the spinBox.
void MainWindow::label_HT_Cost_Set(int Num)
{
dHT = Num - old_HT;
old_HT = Num;
ui->label_HT_Cost_2->setNum((Num-10)*10);
adjust_FP(-99);
adjust_Unspent_Points();
}
void MainWindow::adjust_FP(int Num)
{
if (Num==-99) { // entered by HT
count_FP += 1;
ui->spinBox_FP_2->setValue(old_FP+dHT);
old_FP += dHT;
}
else if (count_FP == 0 ) { // entered by changing spinBox
count_FP += 1;
dFP = Num - old_FP;
cost_FP += dFP * 3;
ui->label_FP_Cost_2->setNum(cost_FP);
ui->spinBox_FP_2->setValue(old_FP+dFP);
old_FP = Num;
count_FP = 0;
adjust_Unspent_Points();
}
else count_FP = 0; //entered by a looping repeat
}
--
Douglas E Knapp
Why do we live?
More information about the Qt-interest-old
mailing list