[Qt-interest] Calling member functions of potentially null QDomElements
Ellen Kestrel
dragonflykes at gmail.com
Sat Aug 8 07:35:09 CEST 2009
Is it safe to call member functions of QDomElements which might be null?
The documentation states that some functions may return "null" QDomElements
in certain circumstances (e.g. QDomNode::toElement () if the node is not an
element, or QDomElement::firstChildElement (QString tagName) if no such
child exists).
For example, is it safe to do this:
QString text = domNode.firstChildElement ("mytag").text ();
or should I be breaking this statement into two lines and adding a check to
QDomNode::isNull ()? I would expect that the call above would simply result
in a return value of "" if there isn't a child node with the "mytag" tag,
but I just wanted to check.
- EK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090807/2689a6a1/attachment.html
More information about the Qt-interest-old
mailing list