neu242
neu242

Reputation: 16575

One-line instantiation of QVector with values without using <<

I can instantiate a QVector containing three QColor values with QVector<QColor>() << x << y << z.

Is it possible to instantiate it on one line without using the overloaded <<? Something like QVector<QColor>().addAll(x,y,z)?

Upvotes: 1

Views: 1046

Answers (1)

Joseph Mansfield
Joseph Mansfield

Reputation: 110698

In C++11, you can use QVector's initializer list constructor:

QVector<QColor>{x, y, z}

Upvotes: 4

Related Questions