How to initialize QStringList as Empty

QStringList list;
In the above code will generate an empty list.

list=QStringLIst();
This is used for initializing the QStringList as Empty.

Eg:
    QStringList list;
    list << "Web" << "Speckle";

    if(list.isEmpty())
    {
         qDebug("empty");
    }
    else
    {
         qDebug("not empty");
    }


//initializing the QStringList as Empty.
    list=QStringList();
    if(list.isEmpty())
    {
         qDebug("empty");
    }
    else
    {
         qDebug("not empty");
    }


Output of the above code is
not empty
empty

No comments:

Post a Comment