Hi
I am working in winХР, qt.4.3.3.
First will show my code:
#include <QVector>
#include <QList>
#include <QString>
#include <QImage>
//#include <list.h>
//#include <vector.h>
typedef struct{
unsigned int x;
unsigned int y;
unsigned int z;
unsigned short int A1;
unsigned short int A2;
unsigned short int A3;
unsigned short int A4;
unsigned short int A[1024];
} dataPoint;
typedef struct{
QVector<dataPoint> dataVector;
} dataScan;
class DataStorage
{
//Q_OBJECT
public:
DataStorage();
QVector<dataPoint> point;
QList<dataScan> dataContainer;
QList<dataScan>::iterator dataContainerIterator;
};
#include <QVector>
#include <QList>
#include <QString>
#include <QImage>
//#include <list.h>
//#include <vector.h>
typedef struct{
unsigned int x;
unsigned int y;
unsigned int z;
unsigned short int A1;
unsigned short int A2;
unsigned short int A3;
unsigned short int A4;
unsigned short int A[1024];
} dataPoint;
typedef struct{
QVector<dataPoint> dataVector;
QImage preview;
QString author;
QString date;
QString time;
} dataScan;
class DataStorage
{
//Q_OBJECT
public:
DataStorage();
QVector<dataPoint> point;
QList<dataScan> dataContainer;
QList<dataScan>::iterator dataContainerIterator;
};
To copy to clipboard, switch view to plain text mode
I need to get access to elements of structure dataContainer and dataVector which is an element of dataContainer. I tried various ways, but at execution the program gives out errors like "QVector: index out of range". When I used classical C++ list and vector I receive RuntimeError.
Below some ways with which I tried to get access to the necessary elements of structures
are shown. But any of them does not work.
DataStorage::DataStorage()
{
const int nPoints = 360;
int q=0;
dataContainerIterator = dataContainer.begin();
for (int i=0;i<=nPoints;i++)
{
q = qAbs(qRound(100*sin(i*3.14/180)));
dataContainerIterator->dataVector[i].x << i;
dataContainerIterator->dataVector[i].x = i;
dataContainerIterator->dataVector.at(i).x << 1;
}
}
DataStorage::DataStorage()
{
const int nPoints = 360;
int q=0;
dataContainerIterator = dataContainer.begin();
for (int i=0;i<=nPoints;i++)
{
q = qAbs(qRound(100*sin(i*3.14/180)));
dataContainerIterator->dataVector[i].x << i;
dataContainerIterator->dataVector[i].x = i;
dataContainerIterator->dataVector.at(i).x << 1;
}
}
To copy to clipboard, switch view to plain text mode
Where is my mistake?
Bookmarks