QString的isNull与isEmpty

测试:

    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。

猜你喜欢

转载自blog.csdn.net/weixin_51883798/article/details/135012316