本文整理汇总了C++中Question::setQuestion方法的典型用法代码示例。如果您正苦于以下问题:C++ Question::setQuestion方法的具体用法?C++ Question::setQuestion怎么用?C++ Question::setQuestion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Question
的用法示例。
在下文中一共展示了Question::setQuestion方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: datamatrixToQuestions
bool Import::datamatrixToQuestions(){
bool success = false;
cout << "START READING DATA TO QUESTION OBJECTS" << endl;
// fills CSV Data from vector < vector <...> > datamatrix to questiondata objects.
int m = dataMatrix[0].size();
// check dimensions of datamatix
if(m!=questionTypes.size()){
cout << "ERROR: number of survey questions != number of questiontypes" << endl;
QMessageBox msgBox;
msgBox.setText("FEHLER: Der ausgewählte Ausstellungstyp passt nicht zur .CSV Datei.");
msgBox.setInformativeText("Bitte richtigen Ausstellungstyp wählen.");
msgBox.setDefaultButton(QMessageBox::Ok);
int ret = msgBox.exec();
success = false;
return success;
}
int id=0;
for(int i=0; i<m;++i){
if(questionTypes[i].toInt()!=0){
Question *tempQuestion = new Question;
tempQuestion->setQuestiontype(questionTypes[i].toInt());
tempQuestion->setQuestion(QString::fromStdString(dataMatrix[0][i]));
tempQuestion->setSubquestion(QString::fromStdString(dataMatrix[1][i]));
if(tempQuestion->getQuestionType()!=6)
tempQuestion->setDataFromStdStringMatrix(dataMatrix,i);
else
tempQuestion->setTextAnswersFromStdStringMatrix(dataMatrix,i);
if(tempQuestion->getQuestion()!="")
++id;
tempQuestion->write_ID(id); // a question and its subquestions share the same id
questions.push_back(*tempQuestion);
delete tempQuestion;
}
}
success=true;
return success;
}
示例2: initQuestions
void QuestionSetCubics::initQuestions( Question::List &questions )
{
for( int b = 1; b <= 10; ++b ) {
Question q;
q.setQuestion( QString::number( b ) + " cube" );
q.setAnswer( QString::number( b * b * b ) );
questions.append( q );
}
}
示例3: parseQuestions
void EngineerExam::parseQuestions(QString filename) {
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName(filename);
if (!db.open()) {
qCritical() << trUtf8("Nie można otworzyć bazy danych!");
}
QSqlTableModel question;
question.setTable("Question");
question.select();
QSqlTableModel answers;
answers.setTable("Answer");
answers.select();
QStringList qsl;
int i = 0;
while (question.canFetchMore()) {
question.fetchMore();
for (; i < question.rowCount(); ++i) {
qsl.clear();
quint32 id = question.record(i).value("Id").toUInt();
QString text = question.record(i).value("Text").toString();
Question q;
q.setId(id);
q.setQuestion(text);
answers.setFilter(QString("`id_Question` = %1").arg(id));
QString a1 = answers.record(0).value("Text").toString();
QString a2 = answers.record(1).value("Text").toString();
QString a3 = answers.record(2).value("Text").toString();
qsl << a1 << a2 << a3;
bool correct1 = answers.record(0).value("IsTrue").toBool();
bool correct2 = answers.record(1).value("IsTrue").toBool();
bool correct3 = answers.record(2).value("IsTrue").toBool();
if (correct1) {
q.setCorrectAnswer(0);
} else if (correct2) {
q.setCorrectAnswer(1);
} else if (correct3) {
q.setCorrectAnswer(2);
}
q.setAnswers(qsl);
tmpList.append(q);
}
}
}
示例4: initQuestions
void QuestionSetMultiplication::initQuestions( Question::List &questions )
{
QValueList<int> rows = Prefs::multiplicationRows();
QValueList<int>::ConstIterator it;
for( it = rows.begin(); it != rows.end(); ++it ) {
int a = *it;
for( int b = 1; b <= 10; ++b ) {
Question q;
q.setQuestion( QString::number( b ) + " \xb7 " + QString::number( a ) );
q.setAnswer( QString::number( a * b ) );
questions.append( q );
}
}
}