Results 1 to 2 of 2

Thread: Problem with view on LCDNumber

  1. #1
    Join Date
    Mar 2011
    Posts
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Unhappy Problem with view on LCDNumber

    Hi All,
    I start to learn the QT but I have some problem with an example that I'm try to develop.

    This is the part of the code
    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3. #include "QIntegerForSize"
    4. #include "QTimer"
    5. #include "QLabel"
    6. #include "QString"
    7. #include "mainwindow.h"
    8.  
    9. int a;
    10. int c;
    11. bool b;
    12.  
    13. MainWindow::MainWindow(QWidget *parent) :
    14. QMainWindow(parent),
    15. ui(new Ui::MainWindow)
    16. {
    17. ui->setupUi(this);
    18. }
    19.  
    20.  
    21. MainWindow::~MainWindow()
    22. {
    23. delete ui;
    24. }
    25.  
    26. void MainWindow::GreenUnoClick()
    27. {
    28. if (b != true)
    29. {
    30. a = (a*10) + 1;
    31. }
    32. else
    33. {
    34. c = ui->lcdNumber->intValue();
    35. a = 1;
    36. }
    37.  
    38. b = true;
    39. ui->lcdNumber->display(a);
    40. QTimer *timer = new QTimer(this);
    41. connect(timer, SIGNAL(timeout()), this, SLOT(AddValueLCD()));
    42. timer->setSingleShot(true);
    43. timer->start(5000);
    44.  
    45. }
    46.  
    47. void MainWindow::AddValueLCD()
    48. {
    49. c = c + a;
    50. ui->lcdNumber->display(c);
    51. }
    To copy to clipboard, switch view to plain text mode 

    What I want do but is :
    1st
    When I press two time the button 1 in this case it write on the LCD "11" and not 1.
    2nd
    When the timer end it add to my start number not original + 1 + 1 but original + 1.

    Somebody have the possibility to help me ?

    Thank s in advance.

  2. #2
    Join Date
    Mar 2011
    Posts
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Problem with view on LCDNumber

    The thing was easy but I see only today

    If somebody was interested

    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3. #include "QIntegerForSize"
    4. #include "QTimer"
    5. #include "QLabel"
    6. #include "QString"
    7. #include "mainwindow.h"
    8.  
    9.  
    10. int a;
    11. int c;
    12. bool b;
    13. char Sa;
    14. int TimWai=2000;
    15.  
    16. MainWindow::MainWindow(QWidget *parent) :
    17. QMainWindow(parent),
    18. ui(new Ui::MainWindow)
    19. {
    20. ui->setupUi(this);
    21. }
    22.  
    23.  
    24. MainWindow::~MainWindow()
    25. {
    26. delete ui;
    27. }
    28.  
    29. void MainWindow::GreenUnoClick()
    30. {
    31.  
    32. if (b == true)
    33. {
    34. a = (a*10) + 1;
    35. }
    36. else
    37. {
    38. c = ui->lcdNumber->intValue();
    39. a = 1;
    40. }
    41. Sa = a;
    42.  
    43. ui->lcdNumber->display(a);
    44. if (b == false)
    45. {
    46. QTimer *timer = new QTimer(this);
    47. connect(timer, SIGNAL(timeout()), this, SLOT(AddValueLCD()));
    48. timer->setSingleShot(true);
    49. timer->start(TimWai);
    50. }
    51. b = true;
    52.  
    53. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Problem with Graphics view
    By denumbaone in forum Newbie
    Replies: 3
    Last Post: 25th February 2011, 10:42
  2. Model Or View problem
    By Nefastious in forum Newbie
    Replies: 2
    Last Post: 9th October 2009, 19:44
  3. QTableWidget view problem
    By zgulser in forum Qt Tools
    Replies: 6
    Last Post: 5th March 2009, 06:50
  4. problem with tree view
    By boss_bhat in forum Newbie
    Replies: 4
    Last Post: 4th June 2006, 21:03
  5. Replies: 3
    Last Post: 20th April 2006, 11:21

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
  •  
Qt is a trademark of The Qt Company.