InterFiction
18th November 2011, 15:59
Creating a simple program with tab widget. User checks boxes that pertain to them, and after pressing button on the calculate tab it measures their good, and evil. Just a simple program to learn some QT.
right now the button isn't doing what I'd like it to do. When it's pressed all my dialogues come up, instead of the ones that should come up. I have a dialogue for if good == evil, and a dialog for if nothing is checked, and a dialogue for if some of the suicidal boxes are checked, and will implement one for if evil is greater than good, and if good is greater than evil. simple program, but I'm not sure about what I'm doing, lol. Here's the code for the button.
void MainWindow::on_CalcGoodEvil_clicked()
{
// Initialises Variables To Handle Good and Evil Values.
int Good = 0;
int Evil = 0;
// Handled Good Traits tab
if (ui->chkKind->isChecked()){
Good += 1;}
if (ui->chkCaring->isChecked()){
Good += 1;}
if (ui->chkSharing->isChecked()){
Good += 1;}
if (ui->chkSharing->isChecked()){
Good += 1;}
if (ui->chkLoving->isChecked()){
Good += 1;}
if (ui->chkHelpful->isChecked()){
Good += 1;}
if (ui->chkDoRight->isChecked()){
Good += 1;}
if (ui->chkObeyTruth->isChecked()){
Good +=1;}
if (ui->chkDonate->isChecked()){
Good += 1;}
if (ui->chkGiveToHomeless->isChecked()){
Good += 1;}
if (ui->chkObedient->isChecked()){
Good += 1;}
if (ui->chkCompassionate->isChecked()){
Good += 1;}
if (ui->chkWontSteerWrong->isChecked()){
Good += 1;}
if (ui->chkWontLie->isChecked()){
Good += 1;}
if (ui->chkNeverStole->isChecked()){
Good += 1;}
if (ui->chkDontLitter->isChecked()){
Good += 1;}
if (ui->chkHelpInNeed->isChecked()){
Good += 1;}
if (ui->chkSolveWorldHunger->isChecked()){
Good += 1;}
if (ui->chkCarAboutFriends->isChecked()){
Good += 1;}
if (ui->chkHumble->isChecked()){
Good += 1;}
if (ui->chkBlissful->isChecked()){
Good += 1;}
if (ui->chkContent->isChecked()){
Good += 1;}
if (ui->chkOptimistic->isChecked()){
Good += 1;}
if (ui->chkStrong->isChecked()){
Good += 1;}
if (ui->chkPatient->isChecked()){
Good += 1;}
if (ui->chkPure->isChecked()){
Good += 1;}
if (ui->chkNeeded->isChecked()){
Good += 1;}
if (ui->chkImSmart->isChecked()){
Good += 1;}
if (ui->chkWise->isChecked()){
Good += 1;}
if (ui->chkResilient->isChecked()){
Good += 1;}
if (ui->chkOutGoing->isChecked()){
Good += 1;}
if (ui->chkSerene->isChecked()){
Good += 1;}
if (ui->chkIntuitive->isChecked()){
Good += 1;}
if (ui->chkIdealistic->isChecked()){
Good += 1;}
if (ui->chkConfident->isChecked()){
Good += 1;}
if (ui->chkHappy->isChecked()){
Good += 1;}
if (ui->chkAttentetive->isChecked()){
Good += 1;}
if (ui->chkAchieving->isChecked()){
Good += 1;}
// Hadnles Evil Traits Tab
if (ui->chkLoveNightmares->isChecked()){
Evil += 1;}
if (ui->chkImJelous->isChecked()){
Evil += 1;}
if (ui->chkImEnvious->isChecked()){
Evil += 1;}
if (ui->chkIGetAngry->isChecked()){
Evil += 1;}
if (ui->chkEnjoyRage->isChecked()){
Evil += 1;}
if (ui->chkMakeFunOfPeople->isChecked()){
Evil += 1;}
if (ui->chkISteal->isChecked()){
Evil += 1;}
if (ui->chkICheat->isChecked()){
Evil += 1;}
if (ui->chkIRob->isChecked()){
Evil += 1;}
if (ui->chkISwindle->isChecked()){
Evil += 1;}
if (ui->chkLieAlot->isChecked()){
Evil += 1;}
if (ui->chkImALiar->isChecked()){
Evil += 1;}
if (ui->chkImGreedy->isChecked()){
Evil += 1;}
if (ui->chkImBelligerent->isChecked()){
Evil += 1;}
if (ui->chkImAFool->isChecked()){
Evil += 1;}
if (ui->chkSelfish->isChecked()){
Evil += 1;}
if (ui->chkBackBitter->isChecked()){
Evil += 1;}
if (ui->chkIgnorant->isChecked()){
Evil += 1;}
if (ui->chkCheap->isChecked()){
Evil += 1;}
if (ui->chkNotFogiving->isChecked()){
Evil += 1;}
if (ui->chkBitter->isChecked()){
Evil+= 1;}
if (ui->chkBalckDescribesMe->isChecked()){
Evil += 1;}
if (ui->chkImViolent->isChecked()){
Evil += 1;}
if (ui->chkImMurderous->isChecked()){
Evil += 1;}
if (ui->chkImAMooch->isChecked()){
Evil += 1;}
if (ui->chkFoolish->isChecked()){
Evil += 1;}
if (ui->chkUnwise->isChecked()){
Evil += 1;}
if (ui->chkNotCaring->isChecked()){
Evil += 1;}
if (ui->chkTief->isChecked()){
Evil += 1;}
if (ui->chkCowering->isChecked()){
Evil += 1;}
if (ui->chkSpiteful->isChecked()){
Evil += 1;}
if (ui->chkUnGreatful->isChecked()){
Evil += 1;}
if (ui->chkLazy->isChecked()){
Evil += 1;}
if (ui->chkVain->isChecked()){
Evil += 1;}
if (ui->chkThoughless->isChecked()){
Evil += 1;}
if (ui->chkRebellious->isChecked()){
Evil += 1;}
if (ui->chkWasteful->isChecked()){
Evil += 1;}
///that concludes all the tabs. Now Comes The Logic for that mathmatical side of things.
if (ui->chkSuicidal->isChecked() || ui->chkThinkAboutDying || ui->chkTryToDie->isChecked()
|| ui->chkTryToDie->isChecked() || ui->chkWouldLikeToDie->isChecked() || ui->chkWillKillMyself->isChecked()){
QMessageBox::warning(this,"Warning!","I see that you've clicked one of the many suicidal check boxes under the life tab. If you've checked these with all seriousness in mind you might want to consult someone about any life issues that are giving you trouble. Remember, it's not all that bad :");
}
//Handles if the user hasn't clicked anything.
if (Good == 0 && Evil == 0 ){
QMessageBox::warning(this,"Alert","You haven't clicked any of, the choices!"); }
//Handles if good and evil is equal
if (Good == Evil){
QMessageBox::information(this,"Findings","You have a perfect balance of good, and evil! You may want to think about the bad things in your life, and how you can get rid of them. As far as the good things go Keep Up The Good Work!");
}
right now the button isn't doing what I'd like it to do. When it's pressed all my dialogues come up, instead of the ones that should come up. I have a dialogue for if good == evil, and a dialog for if nothing is checked, and a dialogue for if some of the suicidal boxes are checked, and will implement one for if evil is greater than good, and if good is greater than evil. simple program, but I'm not sure about what I'm doing, lol. Here's the code for the button.
void MainWindow::on_CalcGoodEvil_clicked()
{
// Initialises Variables To Handle Good and Evil Values.
int Good = 0;
int Evil = 0;
// Handled Good Traits tab
if (ui->chkKind->isChecked()){
Good += 1;}
if (ui->chkCaring->isChecked()){
Good += 1;}
if (ui->chkSharing->isChecked()){
Good += 1;}
if (ui->chkSharing->isChecked()){
Good += 1;}
if (ui->chkLoving->isChecked()){
Good += 1;}
if (ui->chkHelpful->isChecked()){
Good += 1;}
if (ui->chkDoRight->isChecked()){
Good += 1;}
if (ui->chkObeyTruth->isChecked()){
Good +=1;}
if (ui->chkDonate->isChecked()){
Good += 1;}
if (ui->chkGiveToHomeless->isChecked()){
Good += 1;}
if (ui->chkObedient->isChecked()){
Good += 1;}
if (ui->chkCompassionate->isChecked()){
Good += 1;}
if (ui->chkWontSteerWrong->isChecked()){
Good += 1;}
if (ui->chkWontLie->isChecked()){
Good += 1;}
if (ui->chkNeverStole->isChecked()){
Good += 1;}
if (ui->chkDontLitter->isChecked()){
Good += 1;}
if (ui->chkHelpInNeed->isChecked()){
Good += 1;}
if (ui->chkSolveWorldHunger->isChecked()){
Good += 1;}
if (ui->chkCarAboutFriends->isChecked()){
Good += 1;}
if (ui->chkHumble->isChecked()){
Good += 1;}
if (ui->chkBlissful->isChecked()){
Good += 1;}
if (ui->chkContent->isChecked()){
Good += 1;}
if (ui->chkOptimistic->isChecked()){
Good += 1;}
if (ui->chkStrong->isChecked()){
Good += 1;}
if (ui->chkPatient->isChecked()){
Good += 1;}
if (ui->chkPure->isChecked()){
Good += 1;}
if (ui->chkNeeded->isChecked()){
Good += 1;}
if (ui->chkImSmart->isChecked()){
Good += 1;}
if (ui->chkWise->isChecked()){
Good += 1;}
if (ui->chkResilient->isChecked()){
Good += 1;}
if (ui->chkOutGoing->isChecked()){
Good += 1;}
if (ui->chkSerene->isChecked()){
Good += 1;}
if (ui->chkIntuitive->isChecked()){
Good += 1;}
if (ui->chkIdealistic->isChecked()){
Good += 1;}
if (ui->chkConfident->isChecked()){
Good += 1;}
if (ui->chkHappy->isChecked()){
Good += 1;}
if (ui->chkAttentetive->isChecked()){
Good += 1;}
if (ui->chkAchieving->isChecked()){
Good += 1;}
// Hadnles Evil Traits Tab
if (ui->chkLoveNightmares->isChecked()){
Evil += 1;}
if (ui->chkImJelous->isChecked()){
Evil += 1;}
if (ui->chkImEnvious->isChecked()){
Evil += 1;}
if (ui->chkIGetAngry->isChecked()){
Evil += 1;}
if (ui->chkEnjoyRage->isChecked()){
Evil += 1;}
if (ui->chkMakeFunOfPeople->isChecked()){
Evil += 1;}
if (ui->chkISteal->isChecked()){
Evil += 1;}
if (ui->chkICheat->isChecked()){
Evil += 1;}
if (ui->chkIRob->isChecked()){
Evil += 1;}
if (ui->chkISwindle->isChecked()){
Evil += 1;}
if (ui->chkLieAlot->isChecked()){
Evil += 1;}
if (ui->chkImALiar->isChecked()){
Evil += 1;}
if (ui->chkImGreedy->isChecked()){
Evil += 1;}
if (ui->chkImBelligerent->isChecked()){
Evil += 1;}
if (ui->chkImAFool->isChecked()){
Evil += 1;}
if (ui->chkSelfish->isChecked()){
Evil += 1;}
if (ui->chkBackBitter->isChecked()){
Evil += 1;}
if (ui->chkIgnorant->isChecked()){
Evil += 1;}
if (ui->chkCheap->isChecked()){
Evil += 1;}
if (ui->chkNotFogiving->isChecked()){
Evil += 1;}
if (ui->chkBitter->isChecked()){
Evil+= 1;}
if (ui->chkBalckDescribesMe->isChecked()){
Evil += 1;}
if (ui->chkImViolent->isChecked()){
Evil += 1;}
if (ui->chkImMurderous->isChecked()){
Evil += 1;}
if (ui->chkImAMooch->isChecked()){
Evil += 1;}
if (ui->chkFoolish->isChecked()){
Evil += 1;}
if (ui->chkUnwise->isChecked()){
Evil += 1;}
if (ui->chkNotCaring->isChecked()){
Evil += 1;}
if (ui->chkTief->isChecked()){
Evil += 1;}
if (ui->chkCowering->isChecked()){
Evil += 1;}
if (ui->chkSpiteful->isChecked()){
Evil += 1;}
if (ui->chkUnGreatful->isChecked()){
Evil += 1;}
if (ui->chkLazy->isChecked()){
Evil += 1;}
if (ui->chkVain->isChecked()){
Evil += 1;}
if (ui->chkThoughless->isChecked()){
Evil += 1;}
if (ui->chkRebellious->isChecked()){
Evil += 1;}
if (ui->chkWasteful->isChecked()){
Evil += 1;}
///that concludes all the tabs. Now Comes The Logic for that mathmatical side of things.
if (ui->chkSuicidal->isChecked() || ui->chkThinkAboutDying || ui->chkTryToDie->isChecked()
|| ui->chkTryToDie->isChecked() || ui->chkWouldLikeToDie->isChecked() || ui->chkWillKillMyself->isChecked()){
QMessageBox::warning(this,"Warning!","I see that you've clicked one of the many suicidal check boxes under the life tab. If you've checked these with all seriousness in mind you might want to consult someone about any life issues that are giving you trouble. Remember, it's not all that bad :");
}
//Handles if the user hasn't clicked anything.
if (Good == 0 && Evil == 0 ){
QMessageBox::warning(this,"Alert","You haven't clicked any of, the choices!"); }
//Handles if good and evil is equal
if (Good == Evil){
QMessageBox::information(this,"Findings","You have a perfect balance of good, and evil! You may want to think about the bad things in your life, and how you can get rid of them. As far as the good things go Keep Up The Good Work!");
}