Stopping any further processing in nested if statements
I have the following function.
Code:
void haal::authenticate()
{
remoteDB();
int ttwo = query.record().indexOf("two");
int tthree = query.record().indexOf("three");
int ffour = query.record().indexOf("four");
int ffive = query.record().indexOf("five");
int ssix = query.record().indexOf("six");
int sseven = query.record().indexOf("seven");
int eeight = query.record().indexOf("eight");
while (query.next()) {
QString aa
= query.
value(ttwo
).
toString();
QString bb
= query.
value(tthree
).
toString();
QString cc
= query.
value(ffour
).
toString();
QString dd
= query.
value(ffive
).
toString();
QString ee
= query.
value(ssix
).
toString();
QString ff
= query.
value(sseven
).
toString();
QString gg
= query.
value(eeight
).
toString();
if(aa != ui.validator->text())
{
msgBox.setText("That Key Is Not Valid.");
msgBox.exec();
if (msgBox.clickedButton() == connectButton)
{
//close();//exit the application
//qApp->exit(0);...stop further processing;exit the application
//how should it be done..
}
}
if(aa == ui.validator->text())
{
if (msgBox.clickedButton() == connectButton)
{
msgBox.setText("That Key Is Valid.");
}
query.prepare("INSERT INTO princess (one,two,three,four,five,six,seven) "
"VALUES (:one, :two, :three,:four,:five,:six,:seven)");
query.bindValue(":one", 78);
query.bindValue(":two", 7843251);
query.bindValue(":three",79);
query.bindValue(":four",80);
query.bindValue(":five",81);
query.bindValue(":six", 82);
query.bindValue(":seven",kaad);
query.exec();
}
}
}
I need to stop the processing here:
Code:
if (msgBox.clickedButton() == connectButton)
{
//close();//exit the application
//qApp->exit(0);...stop further processing;exit the application
//nothing to be executed below this line
}
Re: Stopping any further processing in nested if statements
to exit while loop or to move to next query result.
Re: Stopping any further processing in nested if statements
I have tried that but the processing continues.
Re: Stopping any further processing in nested if statements
Is the break; line executed , can you see the debug text ?
Code:
while (query.next()) {
....
if(aa != ui.validator->text())
{
....
if (msgBox.clickedButton() == connectButton)
{
qDebug() << "before break";
break;
}
}
everything below the "break" statement will not be executed, same as here:
Code:
#include <iostream>
int main(){
while( 1 ){
std::cout << "in while..."; // this will be visible only once
if( 1 ){
if( 1 ){
break; // while loop will end here
}
}
std::cout << "after break..."; // this will not be visible
}
return 0;
}