Hi, I've problem with an application...the code is something like this one:
class MyDialog: public QDialog
{
<......other code.......>
public slots:
void angleChanged();
private:
QLineEdit leAngle;
}
MyDialog::MyDialog()
{
<......other code.......>
connect(angle, SIGNAL(editingFinished ()), this, SLOT(angleChanged()));
}
void MyDialog::angleChanged()
{
<......other code.......>
double angle = leAngle.text().toDouble();
if (angle<45)
QMessageBox::Warning(this, "Warning", "Angle less than 45°");
double x = sin(angle);
<......other code.......>
}
When I open one instance of MyDialog, change the leAngle with a string like "30" and when this one lost the focus the QMessageBox Dialog appear 2 times, double x = sin(angle) is exectued only the second time that the QMessageBox is called ....Obviously I don't want this strange behaviour.
I investigate and this behaviour is due to the fact that when the QMessageBox is called for the first time the MyDialog lost the focus and so angleChanged is called another time and so QMessageBox too.
How can I resolve this question without remove the connection with the signal editingFinished?
What the meaning of the QWidget::setFocusProxy function?
Bookmarks