2

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?

Tomáš Zato
  • 50,171
  • 52
  • 268
  • 778

1 Answers1

3

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.

Lukáš Bednařík
  • 2,578
  • 2
  • 15
  • 30
  • I was thinking about something more practical. I wrote a method to find nodes based on criteria. To stick with Qt convention, I wanted to return null node if nothing is found. – Tomáš Zato Oct 09 '15 at 13:50
  • Answer fixed. I did not understand your question. It sounds like you ask how to manipulate nodes and how any of them can be null. – Lukáš Bednařík Oct 09 '15 at 13:57