简体   繁体   中英

QT 6.3 convert QVector to std::vector

I am converting my code from QT 5 to QT 6 在此处输入图像描述

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM