QT+C++ .string中的ARG错误
我一直收到错误:请求“学生编号:%1模块代码:%2标记:%3”中的成员“arg”,这是非类类型“const char[43] 我不明白为什么会出现这个错误 以下是产生错误的函数:QT+C++ .string中的ARG错误,c++,qt,C++,Qt,我一直收到错误:请求“学生编号:%1模块代码:%2标记:%3”中的成员“arg”,这是非类类型“const char[43] 我不明白为什么会出现这个错误 以下是产生错误的函数: void StudentForm::displayForm(){ QMessageBox box; box.setIcon(QMessageBox::Information); stuNum = stuEdt->text().toInt(); mark = markSbx->
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();
}
让我知道,如果我需要把更多的代码等。
谢谢
tr首先尝试查找字符串的翻译版本——这是用户可见字符串的一个好习惯
tr首先尝试查找字符串的翻译版本-这是用户可见字符串的一个好习惯。您调用arg时,将其视为字符串文本的一个成员。好的,我如何正确执行此操作?您调用arg时,将其视为字符串文本的一个成员。好的,我如何正确执行此操作?
QString t = QString("Student number:%1 Module Code: %2 Mark: %3").arg(stuNum).arg(modCode).arg(mark);
QString t = tr("Student number:%1 Module Code: %2 Mark: %3").arg(stuNum).arg(modCode).arg(mark);