Important: Please read the Qt Code of Conduct -

Increment the count when ok button is clicked and display it on the button

  • problem: the count value is incremented by 2;
    i have a push buttons by name ok and value;
    i hve connected the ok button to slot on_ok_clicked();
    i have declared int count variable in my .h file under private:
    and assigned a value of 0 in constructor
    when am clicking on, ok button the value is incrementing in this way
    1,3,5,7,9.............................. and am able to display the value on the button
    can u help me where am wrong

    this is my code


    #include "radar.h"
    #include "ui_radar.h"
    #include "iostream"
    using namespace std;

    Radar::Radar(QWidget *parent) :
    ui(new Ui::Radar)

    delete ui;

    void Radar::on_ok_clicked()


    //in radar.h

    int count;--

  • It would be really helpful if you could paste some code that illustrates your problem.

    My first initial thought is that you might have two instances of the same class increment the same value. Or that a the signal is sending a press and a release. Hard to say without any code.

Log in to reply