QString isNull() isEmpty() QList count() size() length()

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;

运行结果:

 

posted @ 2022-01-12 20:36  羽……  阅读(758)  评论(0编辑  收藏  举报