Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Qt Learning Summary (C Fish) QList and QMap container classes

Shulou Source: shulou.com Published: 2022-06-03 05:26:01 10月30日 Update

QList

The QList container is an array list with the following characteristics:

1. You can use QList in most cases. For operations like prepend (), append (), and insert (), QList is usually much faster than QVector. This is because QList stores its element items in memory based on the index tag (although memory is not contiguous, which is the same as STL's list), it is faster than container classes that rely on iterator iterations, and you have less code.

two。 When an iterator points to an item in QList, if the QList inserts or deletes, the iterator is invalid.

The 3.QStringList class inherits from the QList container class (note that QList is actually a class template with QString types in it, and then a QStringList class inherits from it).

Simple use of the QList container (since QStringList inherits from QList, all of the following uses apply equally to the QStringList container):

# include#include # includeint main (int argc, char * argv []) {QCoreApplication a (argc, argv); QList list;// creates a QList container that stores data of type QString inside the container and returns a list object that has many methods to manipulate the container. List

Tags: Container iteration function object item type index element location method storage parameter point move one button memory that is order style number Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi macOS Shulou Information Huawei Microsoft