Hi all,

When I hit the number buttons on screen it invokes the "DotShowing" function with 1 value. If I hit the delete button then invokes the "DotShowing" function with 0 value.

Everything is ok with "DotShowing" function's
Qt Code:
  1. if(butIndex<3){ //butIndex 0 ile 4 arasında olmalı
To copy to clipboard, switch view to plain text mode 
line. But if I change this line to this;
Qt Code:
  1. if(butIndex<4){ //butIndex 0 ile 4 arasında olmalı
To copy to clipboard, switch view to plain text mode 
the problem begins start. Whenever butIndex value exceeds the 4, the butIndex value changing randomly.

What is the difference if(butIndex<4) between if(butIndex<3) or what do I miss?

keypad.h variable definition;
Qt Code:
  1. uint8_t butIndex=0;
To copy to clipboard, switch view to plain text mode 


Qt Code:
  1. #include "keypad.h"
  2. #include "ui_keypad.h"
  3.  
  4.  
  5.  
  6. keypad::keypad(QWidget *parent) :
  7. QDialog(parent),
  8. ui(new Ui::keypad)
  9. {
  10. ui->setupUi(this);
  11. setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint); //Hide close button
  12. setWindowFlags(Qt::FramelessWindowHint); //Remove window frame
  13. //move(604,29); //Start at this location
  14. move(844,340);
  15. }
  16.  
  17. keypad::~keypad()
  18. {
  19. delete ui;
  20. }
  21.  
  22. void keypad::DotShowing(uint8_t val)
  23. {
  24.  
  25.  
  26. if(val){
  27. if(butIndex<3){ //butIndex 0 ile 4 arasında olmalı
  28. butIndex++;
  29. QPixmap mypix (":/Model/SifreEkranicon/şifre-alanı-dolu.png");
  30. switch (butIndex) {
  31. case 1: ui->lb1->setPixmap(mypix);
  32. break;
  33. case 2: ui->lb2->setPixmap(mypix);
  34. break;
  35. case 3: ui->lb3->setPixmap(mypix);
  36. break;
  37. case 4: ui->lb4->setPixmap(mypix);
  38. break;
  39. default:
  40. break;
  41. }
  42. }
  43. }else {
  44. if(butIndex>0){
  45. QPixmap mypix (":/Model/SifreEkranicon/şifre-alanı.png");
  46. switch (butIndex) {
  47. case 1: ui->lb1->setPixmap(mypix);
  48. break;
  49. case 2: ui->lb2->setPixmap(mypix);
  50. break;
  51. case 3: ui->lb3->setPixmap(mypix);
  52. break;
  53. case 4: ui->lb4->setPixmap(mypix);
  54. break;
  55. default:
  56. break;
  57. }
  58. butIndex--;
  59. }
  60. }
  61.  
  62. }
  63.  
  64. void keypad::on_pb15_released() //Close Button
  65. {
  66. this->close();
  67. }
  68.  
  69. void keypad::on_pb14_released() //OK Button
  70. {
  71. if (butValue[0] == 1)
  72. this->close();
  73. }
  74.  
  75. void keypad::on_pb13_released() //Delete Button
  76. {
  77. DotShowing(0); //Nokta eksilt
  78. }
  79.  
  80. void keypad::on_pb1_released() //1
  81. {
  82. DotShowing(1); //Nokta arttır
  83. butValue[butIndex] = 1;
  84.  
  85. }
  86.  
  87. void keypad::on_pb2_released() //2
  88. {
  89. DotShowing(1); //Nokta arttır
  90. butValue[butIndex] = 2;
  91. }
  92.  
  93. void keypad::on_pb3_released() //3
  94. {
  95. DotShowing(1); //Nokta arttır
  96. butValue[butIndex] = 3;
  97. }
  98.  
  99. void keypad::on_pb4_released() //4
  100. {
  101. DotShowing(1); //Nokta arttır
  102. butValue[butIndex] = 4;
  103. }
  104.  
  105. void keypad::on_pb5_released() //5
  106. {
  107. DotShowing(1); //Nokta arttır
  108. butValue[butIndex] = 5;
  109. }
  110.  
  111. void keypad::on_pb6_released() //6
  112. {
  113. DotShowing(1); //Nokta arttır
  114. butValue[butIndex] = 6;
  115. }
  116.  
  117. void keypad::on_pb7_released() //7
  118. {
  119. DotShowing(1); //Nokta arttır
  120. butValue[butIndex] = 7;
  121. }
  122.  
  123. void keypad::on_pb8_released() //8
  124. {
  125. DotShowing(1); //Nokta arttır
  126. butValue[butIndex] = 8;
  127. }
  128.  
  129. void keypad::on_pb9_released() //9
  130. {
  131. DotShowing(1); //Nokta arttır
  132. butValue[butIndex] = 9;
  133. }
  134.  
  135. void keypad::on_pb11_released() //0
  136. {
  137. DotShowing(1); //Nokta arttır
  138. butValue[butIndex] = 0;
  139. }
  140.  
  141. void keypad::on_pb10_released() //*
  142. {
  143. DotShowing(1); //Nokta arttır
  144. butValue[butIndex] = 10;
  145. }
  146.  
  147. void keypad::on_pb12_released() //#
  148. {
  149. DotShowing(1); //Nokta arttır
  150. butValue[butIndex] = 11;
  151. }
To copy to clipboard, switch view to plain text mode