Results 1 to 3 of 3

Thread: on Button Click decrement the data

  1. #1
    Join Date
    Oct 2014
    Posts
    71
    Thanks
    13
    Qt products
    Qt5
    Platforms
    Windows

    Default on Button Click decrement the data

    Hello ,

    In code I am trying to implement, that on every button click my data should be reduce.
    Qt Code:
    1. constructor()
    2. {
    3. connect(ui->pb_uss2ecu_readleft,SIGNAL(clicked()),this,SLOT(Read_File_uss2ecuLeft()));
    4. }
    5. somefunction()
    6. {
    7. uss2ecu_count = 144;
    8. }
    9. Read_File_uss2ecuLeft()
    10. { qDebug()<<"uss2ecu_count_first"<<uss2ecu_count;
    11. uss2ecu_count--;
    12. qDebug()<<"uss2ecu_count_last"<<uss2ecu_count;
    13. }
    To copy to clipboard, switch view to plain text mode 

    My output is
    First Click
    uss2ecu_count_first 144
    uss2ecu_count_last 143
    second Click
    uss2ecu_count_first 189
    uss2ecu_count_last 188

    That is on every time click it is increasing the data rather than taking old data
    My Output should be
    First Click
    uss2ecu_count_first 144
    uss2ecu_count_last 143
    second Click
    uss2ecu_count_first 143
    uss2ecu_count_last 142

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: on Button Click decrement the data

    You haven't posted real code. You've posted some pseudocode that won't even compile, much less run. How do you expect to get help with a problem when you post something that isn't the problem at all? How can we tell what might be going wrong when all you give us is a few scraps of pseudocode?

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: on Button Click decrement the data

    Programming is not magic. If the number is changing then something in your program is changing it. Look at all the places in your real code where you assign a value to uss2ecu_count... One of these must be involved. Then work out how you program gets there.

Similar Threads

  1. How to get the selected row when click the button in it?
    By weixj2003ld in forum Qt Programming
    Replies: 7
    Last Post: 10th November 2011, 10:00
  2. How to prohibit click to button
    By somename in forum Qt Programming
    Replies: 8
    Last Post: 27th May 2010, 22:32
  3. How can I know which button click.
    By electronicboy in forum Qt Programming
    Replies: 10
    Last Post: 4th October 2009, 14:27
  4. button click in webview
    By mind_freak in forum Qt Programming
    Replies: 1
    Last Post: 29th September 2009, 13:48
  5. QPaintEvent on button click?
    By vishal.chauhan in forum Qt Programming
    Replies: 1
    Last Post: 5th June 2007, 08:44

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.