for (int i = 0; i < centerPointsList.size (); i++)
{
QVariant holdInformation = map->page ()->mainFrame ()->evaluateJavaScript (QString ("constructFileName (%1).arg (centerPointsList[0].toFloat())"));
QList <QVariant> allListObj = holdInformation.toList ();
QList <QVariant> fileNamesList = allListObj[0].toList ();
std :: cout << fileNamesList[0].toFloat() << "================= \n";
}
这导致:
“SyntaxError: Parse error on line:1 Source:undefined”
分段错误
我猜测错误在于我将列表项传递给函数的方式evaluateJavaScript
。
更新:
我试过这个:
for (int i = 0; i < centerPointsList.size (); i++)
{
QVariant holdInformation = map->page ()->mainFrame ()->evaluateJavaScript (QString ("constructFileName (%1)").arg (centerPointsList [0].toFloat ()));
这导致:
“TypeError:表达式 'centerPointFileName.split' [undefined] 的结果不是函数。在线:65 来源:file:///.../index.html”
函数constructFileName
(在 Javascript 中)如下:
function constructFileName (centerPointFileName)
{
var removeSpaces = centerPointFileName.split (" ");
var fileNameWithoutSpaces = "", i;
for (i = 0; i < removeSpaces.length; i++)
fileNameWithoutSpaces = fileNameWithoutSpaces + removeSpaces [i];