Clicked() signal triggered by return key when a spin box has focus
-
Hello all,
I have a GUI that has many different widgets on it including mainly QPushButton, QDoubleSpinBox and QCheckBox. Basically i want the slot i set up associated with a clicked() signal from a push button to execute only when the button is pressed. However the behaviour i am getting is when say a spinner has focus and the return key is hit the same slot for the button is executed, suggesting to me that a clicked() signal has been triggered. Below is some test code which demonstrates this behaviour, it just has a button and a spinner on UI.
TestForm.h
@class TestForm : public QDialog {
Q_OBJECT
public:
TestForm();
virtual ~TestForm();
public slots:
void Button_clicked();
private:
Ui::TestForm widget;
};@TestForm.cpp
@#include "TestForm.h"TestForm::TestForm() {
widget.setupUi(this);
// Connect to SLOT
connect(widget.pushButton,SIGNAL(clicked()),this,SLOT(Button_clicked()));
}TestForm::~TestForm() {
}void TestForm::Button_clicked()
{
return;
}@What confuses me is that a spinner as far as i can see does not even have a clicked() signal? So my question is can i stop this behaviour in some way? I went down the road of mapping without any sucess.
Any suggestions would be much appreciated. Cheers.
-
Do you have a default button in your dialog?
http://doc.qt.nokia.com/4.7/qpushbutton.html#default-prop
http://qt.gitorious.com/qt/qt/blobs/master/src/gui/dialogs/qdialog.cpp#line674 -
I had the button set to autoDefault = true.
I see what you mean, probably should have read the documentation more closely.
All sorted now, many thanks.