PDA

View Full Version : ‘QLabel& QLabel::operator=(const QLabel&)’ is private error when using vectors



di_zou
29th September 2009, 20:07
I get this error when I am trying to use a vector with values that are a custom class. The custom class inherits QLabel.

I have:


class SomeClass : public QLabel {
.
.
};
I create a vector of SomeClass:

vector<SomeClass> foo;
and then when I do:

foo.push_back(NULL);
I get this error. In eclipse there is a red underline under "class SomeClass : public QLabel {"

caduel
29th September 2009, 20:44
two errors here:
i) you can not copy QObjects (or subclasses like QWidgets), thus you can not put them in containers by value; you can use QList<SomeClass*>, though.
ii) NULL is a pointer, whereas your vector wants an object, which is why you'd get an error even if QLabel was copyable

HTH