PDA

View Full Version : How do I build an Integer List of Lists with QList?



danielperaza
1st June 2011, 21:07
Hi guys. I need a simple Boundary Representation class (a really simple one), which will hold a list of QVector3D's representing vertices (say list A), and a list of integer lists (say list B), which will represent the indexes in A that holds the right vertices to use. List B is just a simple representation of a volume's faces, each one being a list of vertices contained into a larger and ordered list of faces.

I'm doing this in my class:



class Brep : public QObject
{
Q_OBJECT
public:
typedef QList<QVector3D> VertexList;

typedef QList<int> IndexList;


Later on:



private:
Brep::VertexList vert;

QList<Brep::IndexList> idx;
};


In the implementation file:


void Brep::addFace(const Brep::VertexList &vertices, const Brep::IndexList indices)
{

...


QList<int> auxList;
for(it=indices.begin(); it!=indices.end(); it++) {
auxList = *it;


GCC complains:

In member function 'void Brep::addFace(const QList<QVector3D>&, QList<int>)':
../brep.cpp:47: error: no match for 'operator=' in 'it = QList<T>::begin() const [with T = int]()'
/Library/Frameworks/QtCore.framework/Headers/qlist.h:168: note: candidates are: QList<int>::iterator& QList<int>::iterator::operator=(const QList<int>::iterator&)


I'd like to make use of the existing container classes instead of having to write a new one from scratch.

Santosh Reddy
1st June 2011, 22:02
Check your definition of it (iterator)

ChrisW67
2nd June 2011, 01:06
The parameter "indices" is a QList<int>. Your "it" is an iterator on that list so *it is an int. You are trying to assign the QList<int> auxlist the value of an int.