0

我试图QXmlStreamReader通过调用它clear()的方法来清除和重置它,但方法调用似乎没有做任何事情。

QXmlStreamReader reader;
reader.addData(/*some well formed xml*/);
while(!reader.atEnd())
{
    QString name = reader.name().toString();
    
    if(/*some condition*/)
    {
         reader.clear(); // I expect the reader to be reset and cleared in this line
                         // but this line does not appear to change anything
    }
    name = reader.name().toString(); //after clearing, this line returns the same as the line 
                                     // above the if condition
    reader.readNext();
}

我在这里缺少什么,因为我需要清除读者。我不一定要重新启动读者。

4

0 回答 0