Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/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) :
        QMainWindow(parent),
        ui(new Ui::Screenshot)
    {
        ui->setupUi(this);
        
    
        timer = new QTimer(this);
        connect(timer, SIGNAL(timeout()), this, SLOT(timerSlot()));
    
        connect(ui->spinBox, SIGNAL(valueChanged(int value)), this, SLOT(spinBoxSlot(int value)));
    
    }
    
    Screenshot::~Screenshot()
    {
        delete ui;
    }
    void Screenshot::IntervallSpinBox()
    {
        timer->start(int value);
    }
    

  • Lifetime Qt Champion

    Hi

    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)
    {
        timer->start(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