QT 6.3 convert QVector to std::vector

Viewed 104

I am converting my code from QT 5 to QT 6 enter image description here

https://doc.qt.io/qt-5/qvector.html#toStdVector

I have came across this, when noticing toStdVector() function was removed. until now I had a line of code like this

collection.dgValues = imageset.digitalGainValues().toStdVector();

I am now suppose to change it into this?

std::vector<analoggain_type> ag_vec(imageset.analogGainValues().begin(), imageset.analogGainValues().end());
collection.agValues = ag_vec

or is there a nicer way to code this?

1 Answers

Yes, you can do that.

However, it is worth noticing that there is no use for QVector anymore since Qt 6 made it an alias to QList, so you should migrate your code away from it.

However, we decided that QList should be the real class, with implementation, while QVector should just become an alias to QList.

Prefer to use QList as a rule of thumb. QVector is history.

Related