Increment the count when ok button is clicked and display it on the button
-
problem: the count value is incremented by 2;
description:
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 wrongthis is my code
#include "radar.h"
#include "ui_radar.h"
#include "iostream"
using namespace std;Radar::Radar(QWidget *parent) :
QDialog(parent),
ui(new Ui::Radar)
{
ui->setupUi(this);
cnt=0;
}Radar::~Radar()
{
delete ui;
}void Radar::on_ok_clicked()
{
cnt++;
ui->ok->setText(QString::number(cnt));}
//in radar.h
private:
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.