Logo Search packages:      
Sourcecode: qt4-x11 version File versions

template<typename T>
QList< T > QList< T >::mid ( int  pos,
int  length = -1 
) const [inline, inherited]

Returns a list whose elements are copied from this list, starting at position pos. If length is -1 (the default), all elements after pos are copied; otherwise length elements (or all remaining elements if there are less than length elements) are copied.

Definition at line 489 of file qlist.h.

References QList< T >::at(), and QList< T >::size().

Referenced by MainWindow::modelFromFile(), and TreeModel::setupModelData().

    if (length < 0)
        length = size() - pos;
    if (pos == 0 && length == size())
        return *this;
    QList<T> cpy;
    if (pos + length > size())
        length = size() - pos;
    for (int i = pos; i < pos + length; ++i)
        cpy += at(i);
    return cpy;

Generated by  Doxygen 1.6.0   Back to index