I write a class which is extended from QWidget and Now i declare a QDirModel object in .h file and it instantiated in My class contructor... when i compile it gives the following error.. I include all the things whic are necessary..
model.h:18: error: ISO C++ forbids declaration of 'QDirModel' with no type
model.h:18: error: expected ';' before '*' token
model.cpp: In constructor 'DirModel:

irModel(QWidget*)':
model.cpp:10: error: 'iModel' was not declared in this scope
model.cpp:10: error: expected type-specifier before 'QDirModel'
model.cpp:10: error: expected `;' before 'QDirModel'
model.cpp: At global scope:
code is :
{
public:
~DirModel();
void AddFolder(const QString& aFolderName,int aParent = 0);
public:
int iFolderId;
};
DirModel
::DirModel(QWidget* aParent
){
iModel->setReadOnly(false);
iView->setModel(iModel);
iView
->setRootIndex
( iModel
->index
(QString( "/home/randy" ) ) );
}
DirModel::~DirModel()
{
}
void DirModel::AddFolder(const QString& aFolderName,int aParent)
{
// iModel->mkdir(aParent,aFolderName);
}
class DirModel: public QWidget
{
public:
DirModel(QWidget* aParent);
~DirModel();
void AddFolder(const QString& aFolderName,int aParent = 0);
public:
QDirModel* iModel;
QTreeView* iView;
int iFolderId;
};
DirModel::DirModel(QWidget* aParent)
:QWidget(aParent)
{
iModel = new QDirModel(this);
iModel->setReadOnly(false);
iView = new QTreeView(this);
iView->setModel(iModel);
iView->setRootIndex( iModel->index(QString( "/home/randy" ) ) );
}
DirModel::~DirModel()
{
}
void DirModel::AddFolder(const QString& aFolderName,int aParent)
{
// iModel->mkdir(aParent,aFolderName);
}
To copy to clipboard, switch view to plain text mode
Bookmarks