can anyone tell why this program is not working?
am not able to see the directory structure.
(from the printf's i could make out that is is not calling parent and data functions. this code doesnt contains printfs)
#include <QtGui>
{
public:
TestModel()
{
}
{
return model->data(index, role);
}
{
return model->index(row, column, parent);
}
{
return model->parent(index);
}
{
return model->rowCount(parent);
}
{
return model->columnCount(parent);
}
};
int main(int a, char** b)
{
TestModel *mod = new TestModel;
view.setModel(mod);
view.show();
return app.exec();
}
#include <QtGui>
class TestModel : public QAbstractItemModel
{
public:
QDirModel *model;
TestModel()
{
model = new QDirModel();
}
QVariant data(const QModelIndex &index, int role) const
{
return model->data(index, role);
}
QModelIndex index(int row, int column, const QModelIndex &parent) const
{
return model->index(row, column, parent);
}
QModelIndex parent(const QModelIndex &index) const
{
return model->parent(index);
}
int rowCount(const QModelIndex &parent) const
{
return model->rowCount(parent);
}
int columnCount(const QModelIndex &parent) const
{
return model->columnCount(parent);
}
};
int main(int a, char** b)
{
QApplication app(a, b);
TestModel *mod = new TestModel;
QTreeView view;
view.setModel(mod);
view.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Thanks
Bookmarks