I find some code sample with these oddl lines
QList<TDataXml *> *newXMLData = input->getValue<QList<TDataXml *>>();
if(newXMLData)
{
// do things
}
I dont understand if(newXMLData)
. This is a QList. When should statement be true or false? Why not use Qt isEmpty() method instead?
Thanks
if(newXMLData)
checks for nullity, because newXMLData
is a pointer, and therefore it could point to no object, in which case it's value is nullptr
(or NULL
in C++03).
If newXMLData
is not nullptr
, then it will be true
and the if-block will execute, otherwise false
and if-block will not execute.
It is same as (C++11):
if(newXMLData != nullptr) //or if(newXMLData != NULL) in pre C++11
{
//your code
}