[Solved]QDirModel : No display
-
Hello !
I'm starting to discover the Qt Model : QdirModel;
the problem is that i get no display of the discs or anything@#include "window.h"
#include <QtGui>Window::Window(QWidget *parent) :
QMainWindow(parent){
QVBoxLayout *layout = new QVBoxLayout; QDirModel *modele = new QDirModel(this); QTreeView *vue = new QTreeView; vue->setModel(modele);
layout->addWidget(vue);
setLayout(layout);}
@
any ideas about the source of the problem ? thanks a lot -
QDirModel class is obsolete.
you should use "QFileSystemModel":http://qt-project.org/doc/qt-4.8/qfilesystemmodel.html instead -
QMainWindow does inhertit QWidget, so thats not the problem.
The problem is, that you tried to set a layout on QMainWindow itself, instead you should set a QWidget (with a layout set) as "central widget":http://qt-project.org/doc/qt-4.8/qmainwindow.html#setCentralWidget.Nevertheless you still should use QFileSystemModel!