PDA

View Full Version : Big problem with QVector::apend() function



Zander87
3rd April 2010, 11:51
Hello everybody, i am encoutering a problem using the append/push_back funtcion of Qvector:

Doing this with the std works:


testclass test(&j); // just to try the declaration of one object
vector<testclass> table(1,testclass(&j));
table.push_back(&j);

Now doing this with Qt doesn't work:


QVector<testclass> table(1,testclass(&j));
table.push_back(&j);

Code blocks said :
error: no matching function for call to `testclass::testclass()' (error on line 2)
But i don't understand were the programm does such a call ( with no argument to the constructor )

If anybody can help me.. this would be great....
thks

Lykurg
3rd April 2010, 17:10
What is j? and is textclass a subclass of QWidget? If so, you have to store pointers.

wysota
3rd April 2010, 21:23
Your code doesn't make much sense, you know...
You have a vector of objects and you are trying to push a pointer into it. Are you 100% sure this works with std::vector?