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
if(butIndex<3){ //butIndex 0 ile 4 arasında olmalı
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;
if(butIndex<4){ //butIndex 0 ile 4 arasında olmalı
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;
uint8_t butIndex=0;
uint8_t butIndex=0;
To copy to clipboard, switch view to plain text mode
#include "keypad.h"
#include "ui_keypad.h"
ui(new Ui::keypad)
{
ui->setupUi(this);
setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint); //Hide close button
setWindowFlags(Qt::FramelessWindowHint); //Remove window frame
//move(604,29); //Start at this location
move(844,340);
}
keypad::~keypad()
{
delete ui;
}
void keypad::DotShowing(uint8_t val)
{
if(val){
if(butIndex<3){ //butIndex 0 ile 4 arasında olmalı
butIndex++;
QPixmap mypix
(":/Model/SifreEkranicon/şifre-alanı-dolu.png");
switch (butIndex) {
case 1: ui->lb1->setPixmap(mypix);
break;
case 2: ui->lb2->setPixmap(mypix);
break;
case 3: ui->lb3->setPixmap(mypix);
break;
case 4: ui->lb4->setPixmap(mypix);
break;
default:
break;
}
}
}else {
if(butIndex>0){
QPixmap mypix
(":/Model/SifreEkranicon/şifre-alanı.png");
switch (butIndex) {
case 1: ui->lb1->setPixmap(mypix);
break;
case 2: ui->lb2->setPixmap(mypix);
break;
case 3: ui->lb3->setPixmap(mypix);
break;
case 4: ui->lb4->setPixmap(mypix);
break;
default:
break;
}
butIndex--;
}
}
}
void keypad::on_pb15_released() //Close Button
{
this->close();
}
void keypad::on_pb14_released() //OK Button
{
if (butValue[0] == 1)
this->close();
}
void keypad::on_pb13_released() //Delete Button
{
DotShowing(0); //Nokta eksilt
}
void keypad::on_pb1_released() //1
{
DotShowing(1); //Nokta arttır
butValue[butIndex] = 1;
}
void keypad::on_pb2_released() //2
{
DotShowing(1); //Nokta arttır
butValue[butIndex] = 2;
}
void keypad::on_pb3_released() //3
{
DotShowing(1); //Nokta arttır
butValue[butIndex] = 3;
}
void keypad::on_pb4_released() //4
{
DotShowing(1); //Nokta arttır
butValue[butIndex] = 4;
}
void keypad::on_pb5_released() //5
{
DotShowing(1); //Nokta arttır
butValue[butIndex] = 5;
}
void keypad::on_pb6_released() //6
{
DotShowing(1); //Nokta arttır
butValue[butIndex] = 6;
}
void keypad::on_pb7_released() //7
{
DotShowing(1); //Nokta arttır
butValue[butIndex] = 7;
}
void keypad::on_pb8_released() //8
{
DotShowing(1); //Nokta arttır
butValue[butIndex] = 8;
}
void keypad::on_pb9_released() //9
{
DotShowing(1); //Nokta arttır
butValue[butIndex] = 9;
}
void keypad::on_pb11_released() //0
{
DotShowing(1); //Nokta arttır
butValue[butIndex] = 0;
}
void keypad::on_pb10_released() //*
{
DotShowing(1); //Nokta arttır
butValue[butIndex] = 10;
}
void keypad::on_pb12_released() //#
{
DotShowing(1); //Nokta arttır
butValue[butIndex] = 11;
}
#include "keypad.h"
#include "ui_keypad.h"
keypad::keypad(QWidget *parent) :
QDialog(parent),
ui(new Ui::keypad)
{
ui->setupUi(this);
setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint); //Hide close button
setWindowFlags(Qt::FramelessWindowHint); //Remove window frame
//move(604,29); //Start at this location
move(844,340);
}
keypad::~keypad()
{
delete ui;
}
void keypad::DotShowing(uint8_t val)
{
if(val){
if(butIndex<3){ //butIndex 0 ile 4 arasında olmalı
butIndex++;
QPixmap mypix (":/Model/SifreEkranicon/şifre-alanı-dolu.png");
switch (butIndex) {
case 1: ui->lb1->setPixmap(mypix);
break;
case 2: ui->lb2->setPixmap(mypix);
break;
case 3: ui->lb3->setPixmap(mypix);
break;
case 4: ui->lb4->setPixmap(mypix);
break;
default:
break;
}
}
}else {
if(butIndex>0){
QPixmap mypix (":/Model/SifreEkranicon/şifre-alanı.png");
switch (butIndex) {
case 1: ui->lb1->setPixmap(mypix);
break;
case 2: ui->lb2->setPixmap(mypix);
break;
case 3: ui->lb3->setPixmap(mypix);
break;
case 4: ui->lb4->setPixmap(mypix);
break;
default:
break;
}
butIndex--;
}
}
}
void keypad::on_pb15_released() //Close Button
{
this->close();
}
void keypad::on_pb14_released() //OK Button
{
if (butValue[0] == 1)
this->close();
}
void keypad::on_pb13_released() //Delete Button
{
DotShowing(0); //Nokta eksilt
}
void keypad::on_pb1_released() //1
{
DotShowing(1); //Nokta arttır
butValue[butIndex] = 1;
}
void keypad::on_pb2_released() //2
{
DotShowing(1); //Nokta arttır
butValue[butIndex] = 2;
}
void keypad::on_pb3_released() //3
{
DotShowing(1); //Nokta arttır
butValue[butIndex] = 3;
}
void keypad::on_pb4_released() //4
{
DotShowing(1); //Nokta arttır
butValue[butIndex] = 4;
}
void keypad::on_pb5_released() //5
{
DotShowing(1); //Nokta arttır
butValue[butIndex] = 5;
}
void keypad::on_pb6_released() //6
{
DotShowing(1); //Nokta arttır
butValue[butIndex] = 6;
}
void keypad::on_pb7_released() //7
{
DotShowing(1); //Nokta arttır
butValue[butIndex] = 7;
}
void keypad::on_pb8_released() //8
{
DotShowing(1); //Nokta arttır
butValue[butIndex] = 8;
}
void keypad::on_pb9_released() //9
{
DotShowing(1); //Nokta arttır
butValue[butIndex] = 9;
}
void keypad::on_pb11_released() //0
{
DotShowing(1); //Nokta arttır
butValue[butIndex] = 0;
}
void keypad::on_pb10_released() //*
{
DotShowing(1); //Nokta arttır
butValue[butIndex] = 10;
}
void keypad::on_pb12_released() //#
{
DotShowing(1); //Nokta arttır
butValue[butIndex] = 11;
}
To copy to clipboard, switch view to plain text mode
Bookmarks