Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

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

    General and Desktop
    2
    2
    1528
    Loading More Posts
    • 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
      janaki last edited by

      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 Reply Quote 0
      • G
        Gennon last edited by

        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 Reply Quote 0
        • First post
          Last post