I have two classes: "numberItem" and "numberLine".
The first is derived from QGraphicsRectItem. It works just fine by itself.
The other one is not really a class - more of a C-style struct - in the sense that all I would like to do is use it as a container for a bunch of related information. Among other things, I want it to contain an array of pointers to the first class.
Below is a simplified version of my code. Can anyone tell me what I'm doing wrong? Thanks so much!
First class:
{
public:
numberItem(int cell_width);
private:
int cell_width;
};
// Constructor for numberItem
numberItem::numberItem(int w = 5)
: cell_width(w)
{
}
class numberItem : public QGraphicsRectItem
{
public:
numberItem(int cell_width);
private:
int cell_width;
};
// Constructor for numberItem
numberItem::numberItem(int w = 5)
: cell_width(w)
{
}
To copy to clipboard, switch view to plain text mode
Second class:
class numberLine
{
public:
// IF I COMMENT OUT THIS LINE, IT COMPILES JUST FINE
QList<numberItem> all_number_items;
QList<int> all_x;
int num;
};
class numberLine
{
public:
// IF I COMMENT OUT THIS LINE, IT COMPILES JUST FINE
QList<numberItem> all_number_items;
QList<int> all_x;
int num;
};
To copy to clipboard, switch view to plain text mode
An the rest of the code:
numberLine get_num_line();
int main(int argc, char **argv){
numberLine num_line;
num_line = get_num_line();
return app.exec();
}
numberLine get_num_line()
{
numberLine x;
return x;
}
numberLine get_num_line();
int main(int argc, char **argv){
QApplication app(argc, argv);
numberLine num_line;
num_line = get_num_line();
return app.exec();
}
numberLine get_num_line()
{
numberLine x;
return x;
}
To copy to clipboard, switch view to plain text mode
When I try to compile, I get a whole litany of unintelligible errors:
instantiated from `void QList<T>::node_copy(QList<T>::Node*, QList<T>::Node*, QList<T>::Node*) [with T = numberItem]'
instantiated from `void QList<T>::detach_helper() [with T = numberItem]'
instantiated from `QList<T>::QList(const QList<T>&) [with T = numberItem]'
instantiated from here
error: `QGraphicsRectItem::QGraphicsRectItem(const QGraphicsRectItem&)' is private
Bookmarks