本文整理汇总了C++中Question::question方法的典型用法代码示例。如果您正苦于以下问题:C++ Question::question方法的具体用法?C++ Question::question怎么用?C++ Question::question使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Question
的用法示例。
在下文中一共展示了Question::question方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkAnswer
void MainView::checkAnswer()
{
if ( mQuestions.count() == 0 ) {
kdError() << "checkAnswer(): no questions." << endl;
return;
}
mReadyTimer.stop();
Question q = *mCurrentQuestion;
QString text = "<qt>";
if ( mAnswerEdit->text() == q.answer() ) {
text += i18n("Correct answer:");
mResultView->incrementCurrentCount();
mQuestions.remove( mCurrentQuestion );
} else {
text += "<font color=\"red\">" + i18n("Wrong answer.") + "</font><br>";
text += i18n("Correct Answer:");
mResultView->incrementWrongCount();
}
text += "<br>";
text += q.question() + " = " + q.answer();
text += "</qt>";
mFeedbackText->setText( text );
if ( mQuestions.count() == 0 ) {
QString text = "<qt>";
text += i18n("<b>Congratulation!</b><br/>");
text += i18n("You answered all questions.<br/>");
text += "<br/>";
if ( mResultView->wrongCount() == 0 ) {
text += i18n("You gave no wrong answers.");
} else {
text += i18n("You gave one wrong answer.",
"You gave %n wrong answers", mResultView->wrongCount() );
}
text += "<br/>";
text += mResultView->rating();
text += "</qt>";
KMessageBox::information( this, text );
mQuestionLabel->setText( "" );
mAnswerEdit->setText( "" );
mAnswerEdit->setEnabled( false );
mOkButton->setEnabled( false );
mFeedbackText->setText( i18n("You won.") );
} else {
newQuestion();
}
}