Hello.
I've a class that contains a QVector and an integer.
Class.h
Public:
QVector<int> vector;
int integer;
class(int, int); //the second one is the length of the vector
Class.h
Public:
QVector<int> vector;
int integer;
class(int, int); //the second one is the length of the vector
To copy to clipboard, switch view to plain text mode
I create a class from main
class(2,5)
class(2,5)
To copy to clipboard, switch view to plain text mode
It creates a random QVector,
but then i can't access from main:
class.integer; //works great
class.vector.size();// tells me 0, and the constructor has show me the values iterating trough the vector.
class.integer; //works great
class.vector.size();// tells me 0, and the constructor has show me the values iterating trough the vector.
To copy to clipboard, switch view to plain text mode
Of course I've #include <QVector> in both of them.
I've created a method to print the contents of the vector from the class and it shows the vector empty. So it seems that the vector does not save the data, only in the constructor.
class.print(); //no data, vector.size() = 0;
What am I missing?
Thank you in advance.
Asier
I've found the mistake.
It was a scope error,
In the implementation file I had again: QVector<int> vector. and it was no necessary since I had declared in the class.h file
Bookmarks