I created a simple login program in C++ GUI but for some reason the condition that makes the if statement true is always true no matter what. I've looked at a bunch of times now and I really don't know whats ccausing this, any input would be appreciated.
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
QString username, password;
username=ui->lineEdit->text();
password=ui->lineEdit_2->text();
truee=0;
if (username=="Brandan")
{
truee=1;
}
if (password=="ABC123")
{
truee=truee+1;
}
if(truee=2)
{
ui->label->setText("Login succesful");
}
else
{
ui->label->setText("Failed");
}
}
if(truee=2)
has to be changed to if(truee==2)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments