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. Increment the count when ok button is clicked and display it on the button
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.8k 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.
  • J Offline
    J Offline
    janaki
    wrote on 27 Jun 2013, 06:04 last edited by
    #1

    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 wrong

    this is my code

    //radar.cpp

    #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;--

    1 Reply Last reply
    0
    • G Offline
      G Offline
      Gennon
      wrote on 27 Jun 2013, 06:12 last edited by
      #2

      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.

      /Gen

      1 Reply Last reply
      0

      1/2

      27 Jun 2013, 06:04

      • Login

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