C++ GUI Condition for if statement always true

user3183586

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");
    }
}
Asanga Dewaguru

if(truee=2) has to be changed to if(truee==2)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

<c:if test= > is always true

From Dev

C: False condition is interpreted as true in if statement

From Dev

Condition always true when reached in while loop

From Dev

If statement is always true

From Dev

Why is this if statement always returning true

From Dev

if condition always returns true (Java)

From Dev

Why is this PHP if condition always true?

From Dev

SQL Server - ignoring always true condition

From Dev

Python - True part of if condition always executes

From Dev

PHP - If statement always evaluating as true?

From Dev

'else if' statement always returns true

From Dev

If statement always true with enum in comparison

From Dev

Compiler: What if condition is always true / false

From Dev

Why does my condition always evaluate as true?

From Dev

C# Condition statement doesn't return true

From Dev

If statement always returning true?

From Dev

If statement second condition always executing

From Dev

WIX Operating System Condition Always true

From Dev

Why is this if statement always returning true

From Dev

Bash: 'if' statement always seems to evaluate first condition as true even when false

From Dev

Why is this PHP if condition always true?

From Dev

awk condition always TRUE in a loop

From Dev

if condition always evaluating true

From Dev

pdo statement always return true

From Dev

If statement always returning true in django

From Dev

Bash Script if condition is always true

From Dev

Term for an if condition that is always true

From Dev

If statement is always coming up true

From Dev

If statement always returns true c#