I have the following function.

Qt Code:
  1. void haal::authenticate()
  2. {
  3. remoteDB();
  4. QSqlQuery query("SELECT * FROM princess");
  5. int ttwo = query.record().indexOf("two");
  6. int tthree = query.record().indexOf("three");
  7. int ffour = query.record().indexOf("four");
  8. int ffive = query.record().indexOf("five");
  9. int ssix = query.record().indexOf("six");
  10. int sseven = query.record().indexOf("seven");
  11. int eeight = query.record().indexOf("eight");
  12. while (query.next()) {
  13. QString aa = query.value(ttwo).toString();
  14. QString bb = query.value(tthree).toString();
  15. QString cc = query.value(ffour).toString();
  16. QString dd = query.value(ffive).toString();
  17. QString ee = query.value(ssix).toString();
  18. QString ff = query.value(sseven).toString();
  19. QString gg = query.value(eeight).toString();
  20.  
  21. if(aa != ui.validator->text())
  22. {
  23. QMessageBox msgBox;
  24. msgBox.setText("That Key Is Not Valid.");
  25. QPushButton *connectButton = msgBox.addButton(tr("Ok"), QMessageBox::AcceptRole);
  26. msgBox.exec();
  27.  
  28. if (msgBox.clickedButton() == connectButton)
  29. {
  30. //close();//exit the application
  31. //qApp->exit(0);...stop further processing;exit the application
  32. //how should it be done..
  33. }
  34. }
  35. if(aa == ui.validator->text())
  36. {
  37. if (msgBox.clickedButton() == connectButton)
  38. {
  39. QMessageBox msgBox;
  40. msgBox.setText("That Key Is Valid.");
  41. }
  42.  
  43. QString kaad = getID();
  44. QSqlQuery query;
  45. query.prepare("INSERT INTO princess (one,two,three,four,five,six,seven) "
  46. "VALUES (:one, :two, :three,:four,:five,:six,:seven)");
  47. query.bindValue(":one", 78);
  48. query.bindValue(":two", 7843251);
  49. query.bindValue(":three",79);
  50. query.bindValue(":four",80);
  51. query.bindValue(":five",81);
  52. query.bindValue(":six", 82);
  53. query.bindValue(":seven",kaad);
  54. query.exec();
  55.  
  56. }
  57. }
  58.  
  59. }
To copy to clipboard, switch view to plain text mode 

I need to stop the processing here:

Qt Code:
  1. if (msgBox.clickedButton() == connectButton)
  2. {
  3. //close();//exit the application
  4. //qApp->exit(0);...stop further processing;exit the application
  5. //nothing to be executed below this line
  6. }
To copy to clipboard, switch view to plain text mode