I am new to QT. I am trying to create a simple file system browser. I have created a separate class for the model and the view class. Here they are:
//modelClass.h
#ifndef MODELCLASS_H
#define MODELCLASS_H
#include <QFileSystemModel>
class modelClass: public QFileSystemModel{
Q_OBJECT
public:
modelClass(); //constructor
QFileSystemModel* createModel(); //creates the QFileSystemModel
//public slots:
private:
};
#endif // MODELCLASS_H
//modelClass.cpp
#include "modelClass.h"
modelClass::modelClass(){
createModel(); //calls to function below
}
QFileSystemModel* modelClass::createModel(){
QFileSystemModel* model = new QFileSystemModel;
model->setRootPath("/");
return model;
}
//systemBrowser.cpp
#include "modelClass.h"
#include <QtGui>
int main(int argc, char *argv[]){
QApplication app(argc, argv);
modelClass model();
QTreeView tree;
tree.setModel(&model);
tree.setSortingEnabled(true);
tree.header()->setResizeMode(QHeaderView::ResizeToContents);
tree.resize(640, 480);
tree.show();
return app.exec();
}
Upon trying to compile this, I get the error:
no matching function for call to 'QTreeView::setModel(modelClass(*)())'
candidates are: virtual void QTreeView::setModel(QAbstractItemModel*)*
Could anyone please help me with this error? I'm sure its just something simple I am missing. Thank you