Welcome! Log In Create A New Profile

Advanced

what the frik is a ....."typedef iterator"

Posted by iva 
Announcements Last Post
Announcement myUnisa availability 21 to 24 March 2019 03/17/2019 02:24PM
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
iva
what the frik is a ....."typedef iterator"
October 09, 2007 10:30PM
i know i know i should just look it up ( and i shall) but if anyones in the mood for explaining it quickly please do smiling smiley
Anonymous User
Re: what the frik is a ....."typedef iterator"
October 09, 2007 10:33PM
lemme summarize for you.
the typedef iterator is based on the abstract pattern
where the implementation is left blank
and for instance:
QList<QString>::iterator i = list.end();
the iterator takes on the QString type
yes, no?
do i r0ck 0r w0t??
iva
Re: what the frik is a ....."typedef iterator"
October 10, 2007 10:49AM
thanks rick i finally got it!

An iterator is used to loop through a collection of same type objects

i think you could use an iterator in one of the other threads where i mentioned the questionaire example wrt the reflection pattern. where you would have to loop through a whole lot of widgets so correct me if i'm wrong could we do this for that case;

say myVariant was passed a list of the widgets on a form

QVariantList list = myVariant.toList();
QVariantList::Iterator it = list.begin();


while(it != list.end())
{
QVariant testV = QVariant(*it);
if (testv.typeName() == "QEditbox"winking smiley -------------> heres where i get stuck Qvariant doesn't have types for any Qwidgets that i can see , even Qvariant::canConvert doesn't have qwidget types!!!

++it;
}t
Anonymous User
Re: what the frik is a ....."typedef iterator"
October 10, 2007 09:57PM
Maybe your problem stems from the fact that widgets are classes and not native types. QVariant is maybe not the class to use to iterate widgets?
Re: what the frik is a ....."typedef iterator"
October 10, 2007 10:16PM
You are using an iterator when you use "foreach", no need to reference it specifically.

Like
QStringList l;
l << "Hi" << "There";
foreach (QString str : lst) {
  qDebug() << str << endl;
}

And for your QVariant problem...
Maybe you can get a QObject from your QVariant and do a typecast.
iva
Re: what the frik is a ....."typedef iterator"
October 11, 2007 08:54AM
thanks guys and good luck with the exam today!!
Sorry, only registered users may post in this forum.

Click here to login