Tutorial by Examples

QStack<T> is a template Qt class providing stack. Its analogue in STL is std::stack. It is last in, first out structure (LIFO). QStack<QString> stack; stack.push("First"); stack.push("Second"); stack.push("Third"); while (!stack.isEmpty()) { cout ...
QVector<T> provides dynamic array template class. It provides better performance in most cases than QList<T> so it should be first choice. It can be initialized in various ways: QVector<int> vect; vect << 1 << 2 << 3; QVector<int> v {1, 2, 3, 4}; Th...
In Qt you should use QLinkedList in case you need to implement linked list. It is fast to append, prepend, insert elements into QLinkedList - O(1), but index lookup is slower than in QList or QVector - O(n). This is normal taking into attention you have to iterate through nodes to find something in...
The QList class is a template class that provides lists. It stores items in a list that provides fast index-based access and index-based insertions and removals. To insert items into the list, you can use operator<<(), insert(), append() or prepend(). For example: operator<<() QList&l...

Page 1 of 1