Important: Please read the Qt Code of Conduct -

Connect QSpinBox with QTimer

  • Hey everyone,
    I think my Problem is a pretty small one for most of you, but I don't get any solution yet, it's my first Qt Programm.

    What I want to do:
    In Qt Designer I added a QSpinBox. The user can choose a value between 1 and 10. This value should get connected to a QTimer, so that I get something like

    timer->start(Value of the QSpinBox)

    Any Tipps or Solution? Thanks a lot!

    Screenshot::Screenshot(QWidget *parent) :
        ui(new Ui::Screenshot)
        timer = new QTimer(this);
        connect(timer, SIGNAL(timeout()), this, SLOT(timerSlot()));
        connect(ui->spinBox, SIGNAL(valueChanged(int value)), this, SLOT(spinBoxSlot(int value)));
        delete ui;
    void Screenshot::IntervallSpinBox()
        timer->start(int value);

  • Lifetime Qt Champion


    connect without using parameter name, just type
    connect(ui->spinBox, SIGNAL(valueChanged(int )), this, SLOT(spinBoxSlot(int )));
    and use the value in slot
    void Screenshot::IntervallSpinBox(int value)

  • Thanks a lot! That helped me out!

  • Lifetime Qt Champion

    hi @franad,

    if your problem is solved, please mark this topic as such. Thanks!

Log in to reply