#includeint main() { QList list = {1, 2, 3, 4, 5}; QList ::const_iterator it = list.cbegin(); while (it != list.cend()) { qInfo() << *it; ++it; } return 0; }
#includeThis example demonstrates how to use cbegin to get the first element of a QList of strings using a constant iterator. The Qt library package is required to use QList.#include int main() { QList list = {"apple", "banana", "carrot", "date"}; QList ::const_iterator it = list.cbegin(); qInfo() << "The first element is" << *it; return 0; }