I`m trying convert QBytearray to QVector<QVector3D>.
extern "C" {
typedef struct {
double **vertexes;
int top_rows_vertexes;
int top_column_vertexes;
double **edges;
int top_rows_edges;
int top_column_edges;
}MATRIX;
int start_processing(const char * file_name, MATRIX *date);
}
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
// сишная часть тут создаем структуру получаем имя файла и запускаем нашу сишную функцию
MATRIX A;
QString name = "../../test.obj";
QByteArray str_name;
str_name += name;
int result = start_processing(str_name, &A);
// тут наполняем массив 3Д координатами
QVector<QVector3D> coords;
for (int i = 0; i < A.top_rows_vertexes; ++i) {
coords.append(QVector3D(A.top_rows_vertexes[0][0], A.vertexes[0][1], A.vertexes[0][2]));
}
but I get an error. "invalid type 'int[int]' for array subscript" I need help. I ask you to explain as simple as possible because i'm just learning.
i`m tried changing type array from double to float... it didn't help
int top_rows_vertexes;
That is a plain integer
A.top_rows_vertexes[0][0]
Here you are trying to index into an integer, which obviously will not work.
You probably want to index into vertexes
like for the other cases:
coords.append(QVector3D(A.vertexes[0][0], A.vertexes[0][1], A.vertexes[0][2]));
But that is rather suspicious also. Presumably you would want to use the loop variable here, so maybe
coords.append(QVector3D(A.vertexes[i][0], A.vertexes[i][1], A.vertexes[i][2]));