環境:QT5.5
QListViewに指定ディレクトリにあるファイルの一覧を表示する。
リンク
http://doc.qt.io/qt-5/qlistview.html
http://doc.qt.io/qt-5/qfilesystemmodel.html
http://doc.qt.io/qt-5/qstring.html
インクルードファイル
#include
#include
#include
QListView *FileList;
QFileSystemModel *FileModel = NULL;
FileList = new QListView;
FileModel = new QFileSystemModel;
FileModel->setFilter( QDir::NoDotAndDotDot | QDir::Files );
FileList->setModel(FileModel);
// C;\Windows以下にあるファイルを FileListに表示
QString strDirPath = "C:/Windows";
FileList->setRootIndex(FileModel->setRootPath(strDirPath));
コメント