QString isEmpty isNull

来源:互联网 发布:cms建站系统源码 编辑:程序博客网 时间:2024/05/21 14:48

bool QString::isEmpty () const

如果字符串为空,也就是如果length() == 0,返回真。因此,零字符串也是空字符串。

    QString a( "" );    a.isEmpty();        // 真    a.isNull();         // 假    QString b;    b.isEmpty();        // 真    b.isNull();         // 真  

也可以参考isNull()和length()。

实例:addressbook/mainwindow.cpp、chart/chartform.cpp、chart/chartform_canvas.cpp、network/networkprotocol/nntp.cpp、qmag/qmag.cpp和qwerty/qwerty.cpp。

bool QString::isNull () const

如果字符串为零,返回真。零字符串总是空的。

    QString a;          // a.unicode() == 0,a.length() == 0    a.isNull();         // 真,因为a.unicode() == 0    a.isEmpty();        // 真  

也可以参考isEmpty()和length()。

实例:i18n/main.cpp和qdir/qdir.cpp。


转自:http://www.kuqin.com/qtdocument/qstring.html

0 0