Skip to content

PythonQt.QtXmlPatterns.QXmlResultItems

QXmlResultItems

PythonQtInstanceWrapper object

Native bases: PythonQtInstanceWrapper

Supplemental documentation: Qt 5 reference:

Detailed Description

QXmlResultItems presents the evaluation of an associated query as a sequence of QXmlItems. The sequence is traversed by repeatedly calling next(), which actually produces the sequence by lazy evaluation of the query.

QXmlQuery query;
query.setQuery("<e/>, 1, 'two'");
QXmlResultItems result;

if (query.isValid()) {
    query.evaluateTo(&result);
    QXmlItem item(result.next());
    while (!item.isNull()) {
        // use item
        item = result.next();
    }
    if (result.hasError()) {
        /* Runtime error! */
    }
}

An effect of letting next() produce the sequence by lazy evaluation is that a query error can occur on any call to next(). If an error occurs, both next() and current() will return the null QXmlItem, and hasError() will return true.

QXmlResultItems can be thought of as an "iterator" that traverses the sequence of query results once, in the forward direction. Each call to next() advances the iterator to the next QXmlItem in the sequence and returns it, and current() always returns the QXmlItem that next() returned the last time it was called.

Note: When using the QXmlResultItems overload of QXmlQuery::evaluateTo() to execute a query, it is advisable to create a new instance of this class for each new set of results rather than reusing an old instance.

Source: https://doc.qt.io/archives/qt-5.15/qxmlresultitems.html

Complete member index

Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.

Member Kind Signature Summary
__init__ function (self, *args: Any, **kwargs: Any) -> None Native constructor; consult class documentation for supported overloads. (shared captured text)
className function (self, *args: Any, **kwargs: Any) -> Any Return the classname of the object (shared captured text)
current function (self) -> Any X.current() -> PythonQt.QtXmlPatterns.QXmlItem
delete function (self, *args: Any, **kwargs: Any) -> Any Deletes the C++ object (at your own risk, my friend!) (shared captured text)
hasError function (self) -> bool X.hasError() -> bool
help function (self, *args: Any, **kwargs: Any) -> Any Shows the help of available methods for this class (shared captured text)
inherits function (self, *args: Any, **kwargs: Any) -> Any Returns if the class inherits or is of given type name (shared captured text)
next function (self) -> Any X.next() -> PythonQt.QtXmlPatterns.QXmlItem