1

I have been getting the error: request for member 'arg' in '("Student number:%1 Module Code: %2 Mark: %3")', which is of non-class type 'const char [43]

can't figure out why I'm getting this error

here is the function that produces the error:

void StudentForm::displayForm(){
    QMessageBox box;
    box.setIcon(QMessageBox::Information);
    stuNum = stuEdt->text().toInt();
    mark = markSbx->text().toInt();
    modCode = codeEdt->text();
    QString t = ("Student number:%1 Module Code: %2 Mark: %3").arg(stuNum).arg(modCode).arg(mark);
    box.setText(t);
    box.exec();
}

let me know if I need to put more of the code up etc. Thanks

2
  • You're calling arg as if it was a member of the string literal. Commented Aug 27, 2013 at 18:22
  • ok, how would I do it correctly? Commented Aug 27, 2013 at 18:23

2 Answers 2

3
QString t = tr("Student number:%1 Module Code: %2 Mark: %3").arg(stuNum).arg(modCode).arg(mark);

tr tries to look up a translated version of the string first - it's a good habit for user-visible strings.

Sign up to request clarification or add additional context in comments.

Comments

1
QString t = QString("Student number:%1 Module Code: %2 Mark: %3").arg(stuNum).arg(modCode).arg(mark);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.