Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Clicked() signal triggered by return key when a spin box has focus

Clicked() signal triggered by return key when a spin box has focus

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cougar
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dangelog
      wrote on last edited by
      #2

      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

      Software Engineer
      KDAB (UK) Ltd., a KDAB Group company

      1 Reply Last reply
      0
      • C Offline
        C Offline
        cougar
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved