小编Sha*_*nks的帖子

带有QList <QString>函数的QT应用程序"追加"

我正在尝试使用以下代码返回从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;
Run Code Online (Sandbox Code Playgroud)

...但它告诉我这个错误:

/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;
Run Code Online (Sandbox Code Playgroud)

我怎样才能使它工作,我试图投入多种类型.

c++ qt qregularexpression

3
推荐指数
1
解决办法
561
查看次数

标签 统计

c++ ×1

qregularexpression ×1

qt ×1