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?