Qt Push Button

I have a question about my code in a push button. I wrote a simple app that users click check boxes on a number of tabs, and then get an output display, and a measure of their good and evil, along with the difference between the two.

There's a lot of code in the button. An error that I'm facing is this. There's a tab with a number of suicidal check boxes under the life tab. If they click one they get a message to go with the regular output of the app. The problem is weather they click the check box or not the dialogue is showing up..

1
2
3
4
  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 :");
    }
Last edited on
man, does anyone else see this topic stretched way out?
I am not a Qt expert so it's doubtful if I can help but I guess that you should check your conditions if that occurs.
Anyway it's hard to tell since you don't mention what is ui (your class widget maybe?) and also all the other conditions.

Your post is displayed this way because your message is vast. Next time just split for displaying reasons:
1
2
3
4
5
6
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 :");
    }
ui is the form class I think. You were right though it was in the conditions.

|| ui->chkThinkAboutDying ||

here I forgot to put is checked, so that condition was always true. lol.
Topic archived. No new replies allowed.