Search code examples
qtsubclassing

Qt subclassing from QWidget


I write my own class which subclass from QWidget And this is my header file

#ifndef GRAPHMATRIX_H
#define GRAPHMATRIX_H

#include "treemodel.h"
#include <QWidget>
#include <Qt/qtableview.h>

class GraphMatrix : public QWidget
{
    Q_OBJECT
public:
    TreeModel& getModel();
    GraphMatrix(QWidget* parent = 0);
    void addTop(QString name);
    void cutComponent(GraphMatrix* component, QVector<int> columns);
private:
    TreeModel model;
    QTableView* view;
public slots:
    void changeValue(const QModelIndex& index);
};

#endif // GRAPHMATRIX_H

And I am getting this error

error C2248: 'QWidget::QWidget' : cannot access private member declared in class 'QWidget'

Can anyone help me?

Updated to add: I find answer, problem is in QList I must write QList. because QList is using copy constructor. Thank you for giving time for my problem


Solution

  • The problem was in QList<GraphMatrix>, I must write QList<GraphMatrix*>, because QList is using a copy constructor.