|  | Home · All Classes · Modules

# QWebElementCollection Class Reference
[QtWebKit module]

The QWebElementCollection class represents a collection of web elements. More...

### Methods

- __init__ (self)
- __init__ (self, QWebElement, QString)
- __init__ (self, QWebElementCollection)
- append (self, QWebElementCollection)
- QWebElement at (self, int)
- int count (self)
- QWebElement first (self)
- QWebElement last (self)
- list-of-QWebElement toList (self)

### Special Methods

- QWebElementCollection __add__ (self, QWebElementCollection)
- QWebElement __getitem__ (self, int)
- QWebElementCollection __iadd__ (self, QWebElementCollection)

## Detailed Description

The QWebElementCollection class represents a collection of web elements.

Elements in a document can be selected using QWebElement.findAll() or using the QWebElement constructor. The collection is composed by choosing all elements in the document that match a specified CSS selector expression.

The number of selected elements is provided through the count() property. Individual elements can be retrieved by index using at().

It is also possible to iterate through all elements in the collection using Qt's foreach macro:

     QWebElementCollection collection = document.findAll("p");
     foreach (QWebElement paraElement, collection) {
         ...
     }

## Method Documentation

### QWebElementCollection.__init__ (self)

Constructs an empty collection.

### QWebElementCollection.__init__ (self, QWebElement, QString)

Constructs a collection of elements from the list of child elements of contextElement that match the specified CSS selector query.

### QWebElementCollection.__init__ (self, QWebElementCollection)

Constructs a copy of other.

### QWebElementCollection.append (self, QWebElementCollection)

Extends the collection by appending all items of other.

The resulting collection may include duplicate elements.

See also operator+=().

### QWebElement QWebElementCollection.at (self, int)

Returns the element at index position i in the collection.

### int QWebElementCollection.count (self)

Returns the number of elements in the collection.

### QWebElement QWebElementCollection.first (self)

Returns the first element in the collection.

See also last(), operator[](), at(), and count().

### QWebElement QWebElementCollection.last (self)

Returns the last element in the collection.

See also first(), operator[](), at(), and count().

### list-of-QWebElement QWebElementCollection.toList (self)

Returns a QList object with the elements contained in this collection.

### QWebElementCollection QWebElementCollection.__add__ (self, QWebElementCollection)

### QWebElement QWebElementCollection.__getitem__ (self, int)

### QWebElementCollection QWebElementCollection.__iadd__ (self, QWebElementCollection)