您的位置:首页 > 编程语言 > Qt开发

Qt: QString::isEmpty()与QString::isNull()区别

2015-07-20 22:45 281 查看
Qt: QString::isEmpty()与QString::isNull()

bool QString::isEmpty () const

Returns true if the string has no characters; otherwise returns false.

Example:

QString().isEmpty(); // returns true
QString("").isEmpty(); // returns true
QString("x").isEmpty(); // returns false
QString("abc").isEmpty(); // returns false
See also size().

bool QString::isNull () const

Returns true if this string is null; otherwise returns false.

Example:

QString().isNull(); // returns true
QString("").isNull(); // returns false
QString("abc").isNull(); // returns false
Qt makes a distinction between null strings and empty strings for historical reasons. For most applications, what matters is whether or not a string contains any data, and this can be determined using the isEmpty() function.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: