测试:
QString str;
qDebug()<<str.isEmpty();
qDebug()<<str.isNull();
str="";
qDebug()<<str.isEmpty();
qDebug()<<str.isNull();
str="1";
qDebug()<<str.isEmpty();
qDebug()<<str.isNull();
结果:
true
true
true
false
false
false
总结:
字符串就这三种类型:
(1)
QString str;
是Null,也是Empty
(2)
str="";
不是Null,是Empty。
(3)
str="1";
非Null,非Empty。