1、QString isNull() isEmpty()
举例说明:
QString str1; if(str1.isNull()) { qDebug()<<"str1 is Null"<<endl; } if(str1.isEmpty()) { qDebug()<<"str1 is Empty"<<endl; } QString str2(""); if(str2.isNull()) { qDebug()<<"str2 is Null"<<endl; } if(str2.isEmpty()) { qDebug()<<"str2 is Empty"<<endl; }
运行结果:
2、QList count() size() length()
QList中这三个函数等价!
举例说明:
QList<int>data; for(int i=0;i<10;i++) { data.append(i); } qDebug()<<"size:"<<data.size()<<endl; qDebug()<<"length:"<<data.length()<<endl; qDebug()<<"count:"<<data.count()<<endl;
运行结果: