我正在尝试使用以下代码将从 QRegularExpression 返回的匹配列表返回到 QList:
QList<QString> list();
QString str ("something by the way");
QRegularExpression reA("pattern");
QRegularExpressionMatchIterator i = reA.globalMatch(str);
while (i.hasNext()) {
QRegularExpressionMatch match = i.next();
if (match.hasMatch()) {
list.append(match.captured(0));
}
}
return list;
...但它向我显示了这个错误:
/home/path/.../file:line# error: request for member 'append' in 'list', which is of non-class type 'QList<QString>()'
list.append(match.captured(0));
/home/path/.../file:line#: error: could not convert 'list' from 'QList<QString> (*)()' to 'QList<QString>'
return list;
我怎样才能让它工作,我尝试过多种类型。