- Qt 5.15
- Qt Core
- C++ Classes
- QList
- Qt 5.15.15 Reference Documentation

# Obsolete Members for QList

The following members of class QList are obsolete. They are provided to keep old source code working. We strongly advise against using them in new code.

## Public Functions

`(obsolete)` void | swap(int i, int j)
`(obsolete)` QSet<T> | toSet() const
`(obsolete)` std::list<T> | toStdList() const

## Static Public Members

`(obsolete)` QList<T> | fromSet(const QSet<T> &set)
`(obsolete)` QList<T> | fromStdList(const std::list<T> &list)

## Member Function Documentation

### `[static]` QList<T> QList::fromSet(const QSet<T> &set)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Returns a QList object with the data contained in set. The order of the elements in the QList is undefined.

Note: Since Qt 5.14, range constructors are available for Qt's generic container classes and should be used in place of this method.

For example, if you have code like

     QSet<int> set;
     // ...
     QList<int> list = QList<int>::fromSet(set);

you can rewrite it as

     QSet<int> set;
     // ...
     QList<int> list(set.begin(), set.end());

See also QList(InputIterator, InputIterator), fromVector(), toSet(), and QSet::toList().

### `[static]` QList<T> QList::fromStdList(const std::list<T> &list)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Returns a QList object with the data contained in list. The order of the elements in the QList is the same as in list.

Note: Since Qt 5.14, range constructors are available for Qt's generic container classes and should be used in place of this method.

For example, if you have code like

     std::list<double> stdlist;
     // ...
     QList<double> list = QList<double>::fromStdList(stdlist);

you can rewrite it as

     std::list<double> stdlist;
     // ...
     QList<double> list(stdlist.begin(), stdlist.end());

See also QList(InputIterator, InputIterator), toStdList(), and QVector::fromStdVector().

### void QList::swap(int i, int j)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use swapItemsAt()

See also move() and swapItemsAt().

### QSet<T> QList::toSet() const

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Returns a QSet object with the data contained in this QList. Since QSet doesn't allow duplicates, the resulting QSet might be smaller than the original list was.

Note: Since Qt 5.14, range constructors are available for Qt's generic container classes and should be used in place of this method.

For example, if you have code like

     QStringList list;
     // ...
     QSet<QString> set = list.toSet();

you can rewrite it as

     QStringList list;
     // ...
     QSet<QString> set(list.begin(), list.end());

See also QSet::QSet(InputIterator, InputIterator), toVector(), fromSet(), and QSet::fromList().

### std::list<T> QList::toStdList() const

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Returns a std::list object with the data contained in this QList. Example:

Note: Since Qt 5.14, range constructors are available for Qt's generic container classes and should be used in place of this method.

For example, if you have code like

     QList<double> list;
     // ...
     std::list<double> stdlist = list.toStdList();

you can rewrite it as

     QList<double> list;
     // ...
     std::list<double> stdlist(list.begin(), list.end());

See also fromStdList() and QVector::toStdVector().