Reputation: 150
I am working on a module in which GUI and back-end interact by message passing. I initialised a char* as nullptr. GUI takes a QStringList which is tokenized. I cannot do the changes in the tokenized list. I receive a "(null)" in the list. Now I feel like by comparing to "(null)" is not the way to go. Is there any initialisation for char* which would be taken as an empty string by QString?
Upvotes: 0
Views: 358
Reputation: 2211
Not sure to understand what you want but if i am not mistaken :
char *c = nullptr;
QString str(c);
str.isEmpty(); // return true
Upvotes: 1
Reputation: 206577
Use an empty string when constructing a QString
when the pointer is NULL
.
QString obj = (ptr == nullptr? QString("") : QString(ptr));
And then use obj
.
Upvotes: 3