QVector<QVector3D> index out of range at pushback operation
I have this typeof data:
Code:
QVector<QVector3D> vector_aux;
QVector<int> indicies;
QVector<QVector3D> vector_coord;
My goal is to rearrange the vector_aux to vector_coord by the value stored in indicies.
If i store my singular data in vector_aux like this no error occured:
Code:
vector_aux << QVector3D( 0.276388, 0.850649, -0.447220)
<< QVector3D( 0.483971, 0.716565, -0.502302) .. and so on till i store 104 data.
The indicies.lenght() => 548
If i try do it and when i stored 500 data the program crash:
..
Ok at = 490
Ok at = 500
ASSERT failure in QVector<T>:: operator[]: "index out of range", file C:\Qt\Qt5.13.1\5.13.1\mingw73_64\include/QtCore/qvector.h, line 448
Code:
for (int i=0; i<indicies.length(); i++){
vector_coord.push_back(vector_aux[indicies[i]]);
if (i%10==0){
qDebug() << "Ok at =" << i;
}
}
There is a limit of 500 data that i can store, or there an other reason for my trouble?
Re: QVector<QVector3D> index out of range at pushback operation
Apparently one of your values in "indicies" is larger or equal vector_aux.length().
According to your printout, you should inspect the values of "indicies" in the range 501 to 510.
Re: QVector<QVector3D> index out of range at pushback operation
Put a qDebug statement at the top of your for() loop
Code:
for (int i=0; i<indicies.length(); i++){
qDebug() << i << indices[i];
(before you try to access vector_aux), and you'll probably discover that "indices" does not contain the values you think it should.
Quote:
.. and so on till i store 104 data.
Anyway, if vector_aux has only 104 QVector3D items in it, why is indices 548 entries long? And why do you try to push 548 items onto vector_coord when you have only 104 coordinates to start with?
Re: QVector<QVector3D> index out of range at pushback operation
yes, my mistake in my code is that one/more value stored in indicies is out or equal vector_aux.length()
i'm trying to extract data from file generated on blender in format -> blender.obj