C:/Qt/.../mymodel.h:-1: In member function 'void MainWindow::createModel()':
error: 'myModel::myModel(QObject*)' is private
error: within this context
mymodel.h:
#ifndef MYMODEL_H
#define MYMODEL_H
#include <QStandardItemModel>
class myModel : public QStandardItemModel
{
public:
Q_OBJECT
myModel(QObject *parent = 0);
};
#endif // MYMODEL_H
mymodel.cpp:
#include "mymodel.h"
myModel::myModel(QObject *parent) :
QStandardItemModel(parent)
{
}
mainwindow.h
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow();
private slots:
...
signals:
...
private:
...
myModel *model;
};
mainwindow.cpp:
void MainWindow::createModel()
{
model = new myModel(this);
Thanks.