Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
QT+C++ .string中的ARG错误_C++_Qt - Fatal编程技术网

QT+C++ .string中的ARG错误

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->

我一直收到错误:请求“学生编号:%1模块代码:%2标记:%3”中的成员“arg”,这是非类类型“const char[43]

我不明白为什么会出现这个错误

以下是产生错误的函数:

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);