Cannot modify QList when using pointer to QList
Posted on 2010-11-15
I've got a class with a number of QLists defined as follows:
Vertex is simply a class I've defined that has 3 public GLdouble members.
I have three functions that do processing on each of the QLists, they are called:
ProcessSurfaces, ProcessWindows, ProcessHoles and are identical apart from the fact I am using a different QList.
So I'd like to refactor those into a single function that takes an int representing whether m_surfaceVertices, m_windowVertices or m_holeVertices are to be processed.
The way I'm doing this is:
QList<Vertex>* theVertices = NULL;
then a switch statement which simple assigns theVertices with the address of the appropriate QList:
theVertices = &m_surfaceVertices
However, when I try to modify the x, y and z members of one of the Vertex is in the QList, I get compiling errors:
theVertices(i).x = 4;
Error 1 error C2039: 'x' : is not a member of 'QList<T>'
I've tried everything I can think of (casting, putting brackets in, using at(J) etc) and don't understand why I can't do this.
After all, I have a pointer to the QList and am accessing a Vertex so should be able to modify it?
Any help is greatly appreciated.
Note: I had to replace square brackets in code above.