C++ 调用重载';arg(QString(&;)())和#x27;使用QApplication::applicationDirPath调用时不明确,为什么?

C++ 调用重载';arg(QString(&;)())和#x27;使用QApplication::applicationDirPath调用时不明确,为什么?,c++,qt,qstring,C++,Qt,Qstring,告诉我上面的错误。我以前使用过.arg(),所以我想知道为什么它会给我这个错误?我的代码中的所有其他.arg()都正常工作。解释 QString msgText = QString("The file has been saved at %1\sysconf.xml").arg(QApplication::applicationDirPath); QApplication::applicationDirPath是一个静态成员函数,要获取您要查找的值,必须将其视为静态成员函数,因此;您必须调用该

告诉我上面的错误。我以前使用过
.arg()
,所以我想知道为什么它会给我这个错误?我的代码中的所有其他
.arg()
都正常工作。

解释

QString msgText = QString("The file has been saved at %1\sysconf.xml").arg(QApplication::applicationDirPath);
QApplication::applicationDirPath
是一个静态成员函数,要获取您要查找的值,必须将其视为静态成员函数,因此;您必须调用该函数

当前,您正试图传递一个指向
QString::arg
的函数指针,由于编译器找不到适合此类构造的重载,因此会引发诊断


解决方案

QString msgText = QString("The file has been saved at %1\sysconf.xml").arg(QApplication::applicationDirPath);

注意:请参见
QApplication::applicationDirPath

后添加的
()
说明

QString msgText = QString("The file has been saved at %1\sysconf.xml").arg(QApplication::applicationDirPath);
QApplication::applicationDirPath
是一个静态成员函数,要获取您要查找的值,必须将其视为静态成员函数,因此;您必须调用该函数

当前,您正试图传递一个指向
QString::arg
的函数指针,由于编译器找不到适合此类构造的重载,因此会引发诊断


解决方案

QString msgText = QString("The file has been saved at %1\sysconf.xml").arg(QApplication::applicationDirPath);

注意:请参见
QApplication::applicationDirPath
之后添加的
()
,尝试实际调用函数:

QString msgText = QString(...).arg(QApplication::applicationDirPath ());

注意applicationDirPath后面的“()”。

尝试实际调用函数:

QString msgText = QString(...).arg(QApplication::applicationDirPath ());
请注意applicationDirPath之后的“()”。

根据您正在传递一个指向静态成员函数的指针
applicationDirPath
,并且
arg
有几个重载,它们都不接受这样一个poitner。编译器似乎发现指向参数类型
arg
的函数指针的多次转换被重载,并且变得混乱。你是说:

QString msgText = QString("The file has been saved at %1\sysconf.xml").arg(QApplication::applicationDirPath());
根据,您正在传递指向静态成员函数的指针
applicationDirPath
,并且
arg
有几个重载,它们都不接受这样的poitner。编译器似乎发现指向参数类型
arg
的函数指针的多次转换被重载,并且变得混乱。你是说:

QString msgText = QString("The file has been saved at %1\sysconf.xml").arg(QApplication::applicationDirPath());

你能提供完整的错误信息吗?它包括通话的实际类型,通常还包括可供选择的功能。我认为有足够多的打字问题。恐怕这个对其他人没有帮助。你能提供完整的错误信息吗?它包括通话的实际类型,通常还包括可供选择的功能。我认为有足够多的打字问题。这个恐怕帮不了任何人。哦,该死,对了!谢谢你的解释。现在它工作了!似乎找到了多个合适的重载,或者错误消息应该不同。威奇让我想知道那些过载可能是什么?哦,该死,对了!谢谢你的解释。现在它工作了!似乎找到了多个合适的重载,或者错误消息应该不同。Wich让我想知道那些重载可能是什么?