What is the right way to initialize a QList?

You could use the following code:

QList<int> list = QList<int>() << 1 << 1;

or initializer list with C++11:

QList<int> list({1, 1});

You can enable the latter with the -std=c++0x or -std=c++11 option for gcc. You will also need the relevant Qt version for that where initializer list support has been added to the QList constructor.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)