qt5qdomdocument

How to return null QDomElement?


Qt XML manipulation is kind of weird - although the QDomElement objects refer to their representations in document, they are not pointers.

To indicate "null" element, isNull method is used. How do I create QDomElement that returns true on isNull?


Solution

  • QDomElement inherits QDomNode. The documentation states:

    bool QDomNode::isNull() const

    Returns true if this node is null (i.e. if it has no type or contents); otherwise returns false.

    and also

    QDomNode::QDomNode()

    Constructs a null node.

    In your example you only need to return QDomElement() as a null node.