Hi, Brian - great tutorial (as usual). Sometime between when you made this video, and the introduction of Qt 5.8, it became necessary to add a step to get this to work. You now have to set the root indexes of the UI items: QString sPath = "/home"; dirModel = new QFileSystemModel(this); dirModel->setFilter(QDir::NoDotAndDotDot | QDir::AllDirs); dirModel->setRootPath(sPath); ui->treeView->setModel(dirModel); QModelIndex index = dirModel->index(sPath, 0); // this line is not in the video. ui->treeView->setRootIndex(index); // this line is not in the video. fileModel = new QFileSystemModel(this); fileModel->setFilter(QDir::NoDotAndDotDot | QDir::Files); dirModel->setRootPath(sPath); ui->listView->setModel(fileModel); index = fileModel->index(sPath, 0); // this line is not in the video. ui->listView->setRootIndex(index); // this line is not in the video. Just FYI.
Nice video. I wasn't quite sure how QT implemented its MVC and this was a quick browse through how it is done in general and in particular for the TreeView+FileModel
hey man, you are the best!!!!! thank you so much for your tutorials, I like that you explain everything so clearly that is just as learning in college. : )
Very useful tutorial. I struggled as the file section was only showing files from the parent directory and didn't get it for a while. Make sure to use QFileInfo::absoluteFilePath() and not QFileInfo::absolutePath() ...
I'm following the tutorials on QT 5.1, the absolutePath() function didn't work well ti only showed the files for the first subdir of each dir, I changed with absoluteFilePath() and it worked well.
This is great. I'm looking for a way to do this using QML. I already have an application that uses a QDeclarativeView object and "setSource(QUrl(/path/main.qml))" to display the GUI drawn with QML. I've got lots of information, but not one example of this done through QML. Any pointers would be appreciated.
For all the people who just need a file explorer, I would advice this line QString filePath = QFileDialog::getOpenFileName(this, "select CSV file",".",'Comma Separated Values (*.csv)"); This is for csv file but you can set any extension you want.
everything works fine, just when i debug it my list view and treeview wont expand with the main window. like when i maximize it they stay the same. any help?
I just downloaded and installed the newest Qt IDE. According to qmake --version I am running 4.8.6 The file type QFileSystemModel can not be found though? I get a "unknown type name 'QFileSystemModel'" error Any help please?
Thanks for the video. Very helpful, but I'm busy with an assignment where I have to use QFileSystemModel to create folders, delete and rename files and folders. I figured out how to create and delete but I cannot seem to find anything in QFileSystemModel which renames files or folders. Help, anyone?
Probably one of the best coding tutorials I've seen. No jarring music, clear easy to understand speech. Good job!
Hi, Brian - great tutorial (as usual).
Sometime between when you made this video, and the introduction of Qt 5.8, it became necessary to add a step to get this to work. You now have to set the root indexes of the UI items:
QString sPath = "/home";
dirModel = new QFileSystemModel(this);
dirModel->setFilter(QDir::NoDotAndDotDot | QDir::AllDirs);
dirModel->setRootPath(sPath);
ui->treeView->setModel(dirModel);
QModelIndex index = dirModel->index(sPath, 0); // this line is not in the video.
ui->treeView->setRootIndex(index); // this line is not in the video.
fileModel = new QFileSystemModel(this);
fileModel->setFilter(QDir::NoDotAndDotDot | QDir::Files);
dirModel->setRootPath(sPath);
ui->listView->setModel(fileModel);
index = fileModel->index(sPath, 0); // this line is not in the video.
ui->listView->setRootIndex(index); // this line is not in the video.
Just FYI.
You are a blessing, thanks!
That is sooo much easier than I expected thanks man
Nice video. I wasn't quite sure how QT implemented its MVC and this was a quick browse through how it is done in general and in particular for the TreeView+FileModel
Nice one. This is really usefull when indeed you don't want to spend time looking at docs, even they are good quality.
Directly to the essential.
Thanks, it was quiet comprehensible even though English is not my native language.
Your Tutorial saved me tons of time. Thanx.
hey man, you are the best!!!!!
thank you so much for your tutorials, I like that you explain everything so clearly that is just as learning in college.
: )
Very useful tutorial.
I struggled as the file section was only showing files from the parent directory and didn't get it for a while.
Make sure to use QFileInfo::absoluteFilePath() and not QFileInfo::absolutePath() ...
This is great.
What options are available for network file paths?
I'm following the tutorials on QT 5.1, the absolutePath() function didn't work well ti only showed the files for the first subdir of each dir, I changed with absoluteFilePath() and it worked well.
This is great. I'm looking for a way to do this using QML. I already have an application that uses a QDeclarativeView object and "setSource(QUrl(/path/main.qml))" to display the GUI drawn with QML. I've got lots of information, but not one example of this done through QML. Any pointers would be appreciated.
For all the people who just need a file explorer, I would advice this line
QString filePath = QFileDialog::getOpenFileName(this, "select CSV file",".",'Comma Separated Values (*.csv)");
This is for csv file but you can set any extension you want.
for new Qt versions :
add #include in the Dialog.h (under header folder)
When you go in directory, then subdirectory in it , then back - QListView show subdirectory even if filter is QDir::Files
What to do with this?
hey, how do you set the path in case of Linux? thanks
Very well done!
Thanks, this was exactly what I needed :)
hi
how to open file by doubleclicked on listview?
Excellent! Thank you very much.
everything works fine, just when i debug it my list view and treeview wont expand with the main window. like when i maximize it they stay the same. any help?
How to make it only show name Column and hide other Columns in the treeview?
Can you teach me how to initialize the splitter handle position?
I just downloaded and installed the newest Qt IDE. According to qmake --version I am running 4.8.6
The file type QFileSystemModel can not be found though? I get a "unknown type name 'QFileSystemModel'" error
Any help please?
same
Include QFileSystemModel in your h file
I have done it
It's important to know that not QDir is obsolete but QDirModel.
Any source code?
Thanks for the video. Very helpful, but I'm busy with an assignment where I have to use QFileSystemModel to create folders, delete and rename files and folders. I figured out how to create and delete but I cannot seem to find anything in QFileSystemModel which renames files or folders. Help, anyone?
How can I add checkboxes before each file listed in the file explorer view?
wow~
While this was interesting and informative, it seems impractical to divide up the models like this
Kellie Spring