Home · All Classes · Main Classes · Grouped Classes · Modules · Functions

QScriptValueIterator Class Reference
[
QtScript module]

The QScriptValueIterator class provides a Java-style iterator for QScriptValue. More...

 #include <QScriptValueIterator>

This class was introduced in Qt 4.3.

Public Functions


Detailed Description

The QScriptValueIterator class provides a Java-style iterator for QScriptValue.

The QScriptValueIterator constructor takes a QScriptValue as argument. After construction, the iterator is located at the very beginning of the sequence of properties. Here's how to iterate over all the properties of a QScriptValue:

 QScriptValue object;
 ...
 QScriptValueIterator it(object);
 while (it.hasNext()) {
   it.next();
   qDebug() << it.name() << ": " << it.value();
 }

The next() function returns the name of the next property and advances the iterator. The name(), value() and flags() functions return the name, value and flags of the last item that was jumped over.

If you want to remove properties as you iterate over the QScriptValue, use remove(). If you want to modify the value of a property, use setValue().

Note that QScriptValueIterator only iterates over the QScriptValue's own properties; i.e. it does not follow the prototype chain.

See also QScriptValue::setProperty().


Member Function Documentation

QScriptValueIterator::QScriptValueIterator ( const QScriptValue & object )

Constructs an iterator for traversing object. The iterator is set to be at the front of the sequence of properties (before the first property).

QScriptValueIterator::~QScriptValueIterator ()

Destroys the iterator.

QScriptValue::PropertyFlags QScriptValueIterator::flags () const

Returns the flags of the last property that was jumped over using next() or previous().

bool QScriptValueIterator::hasNext () const

Returns true if there is at least one item ahead of the iterator, i.e. the iterator is

not at the back of the property sequence; otherwise returns false.

bool QScriptValueIterator::hasPrevious () const

Returns true if there is at least one item behind the iterator, i.e. the iterator is

not at the front of the property sequence; otherwise returns false.

QString QScriptValueIterator::name () const

Returns the name of the last property that was jumped over using next() or previous().

QString QScriptValueIterator::next ()

Returns the name of the next property and advances the iterator by one position.

QString QScriptValueIterator::previous ()

Returns the name of the previous property and moves the iterator back by one position.

void QScriptValueIterator::remove ()

Removes the last property that was jumped over using next() or previous().

void QScriptValueIterator::setValue ( const QScriptValue & value )

Sets the value of the last property that was jumped over using next() or previous().

See also value().

void QScriptValueIterator::toBack ()

Moves the iterator to the back of the QScriptValue (after the last property).

void QScriptValueIterator::toFront ()

Moves the iterator to the front of the QScriptValue (before the first property).

QScriptValue QScriptValueIterator::value () const

Returns the value of the last property that was jumped over using next() or previous().

See also setValue().

QScriptValueIterator & QScriptValueIterator::operator= ( QScriptValue & object )

Makes the iterator operate on object. The iterator is set to be at the front of the sequence of properties (before the first property).


Copyright © 2007 Trolltech Trademarks
Qt 4.3.0beta