QStringList number of items?
-
-
Hi,
Do you mean something like size() ?
-
[quote author="SGaist" date="1377015633"]Hi,
Do you mean something like size() ?[/quote]
No not like size.
lets say we have a
QStringList fonts;
fonts << "Arial" << "Helvetica" << "Times" << "Courier";QString f1;
f1 = fonts[0];
QString f2;
f2 = font[1];now f1 will be Arial and f2 will Helvetica.
So technically, QStringList fonts has 4 items.
so like this can i find the max number of items the QStringList has -
QStringList inherits from QList<QString>
QList has two methods to count the number of items in the list,
int QList::size() const & int QList::count() const.Example:-
QStringList list;
list << "a" <<"b" <<"c" <<"d" << "e" << "f";
qDebug() << list.count(); //or list.size(); ======> 6There is another version for count(), whic is
int QList::count(const T & value) const
this one returns the number of occurrences of value in the list.Example:-
QStringList list;
list << "a" << "c" << "a" << "f" << "a" << "a" << "b";
qDebug() << list.count("a"); =====> 4