C++ Qt 49 - QFileSystemModel a simple file explorer example

Поделиться
HTML-код
  • Опубликовано: 28 янв 2025

Комментарии • 36

  • @JedEvnull
    @JedEvnull 9 лет назад +13

    Probably one of the best coding tutorials I've seen. No jarring music, clear easy to understand speech. Good job!

  • @TheSilverbar
    @TheSilverbar 8 лет назад +24

    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.

    • @xpenzfan
      @xpenzfan 8 месяцев назад

      You are a blessing, thanks!

  • @Roman-uy7qp
    @Roman-uy7qp Год назад +1

    That is sooo much easier than I expected thanks man

  • @jpswensen
    @jpswensen 14 лет назад +1

    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

  • @lewin555
    @lewin555 13 лет назад

    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.

  • @madmentat9596
    @madmentat9596 4 года назад +1

    Thanks, it was quiet comprehensible even though English is not my native language.

  • @thickFruitJuice
    @thickFruitJuice 7 лет назад

    Your Tutorial saved me tons of time. Thanx.

  • @frikstobal
    @frikstobal 12 лет назад

    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.
    : )

  • @elrandira
    @elrandira 4 года назад +1

    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() ...

  • @0Wayne
    @0Wayne 12 лет назад

    This is great.
    What options are available for network file paths?

  • @okbabekhelifi1206
    @okbabekhelifi1206 10 лет назад +2

    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.

  • @ultramanjonez
    @ultramanjonez 12 лет назад

    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.

  • @saperlotteable
    @saperlotteable 9 лет назад +3

    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.

  • @skinpotatoes
    @skinpotatoes 6 лет назад +5

    for new Qt versions :
    add #include in the Dialog.h (under header folder)

  • @doobzzz
    @doobzzz 14 лет назад +2

    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?

  • @BlazeMaddox
    @BlazeMaddox 4 года назад

    hey, how do you set the path in case of Linux? thanks

  • @fugger02
    @fugger02 11 лет назад

    Very well done!

  • @cestarianinhabitant5898
    @cestarianinhabitant5898 10 лет назад

    Thanks, this was exactly what I needed :)

  • @damdat79
    @damdat79 6 лет назад +1

    hi
    how to open file by doubleclicked on listview?

  • @ThanosSiozos
    @ThanosSiozos 11 лет назад

    Excellent! Thank you very much.

  • @WilsonTech-go
    @WilsonTech-go 13 лет назад

    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?

  • @CasperLiHongKong
    @CasperLiHongKong 10 лет назад

    How to make it only show name Column and hide other Columns in the treeview?

  • @CasperLiHongKong
    @CasperLiHongKong 10 лет назад

    Can you teach me how to initialize the splitter handle position?

  • @mrkevinfielding
    @mrkevinfielding 10 лет назад

    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?

  • @aliancemd
    @aliancemd 12 лет назад +1

    It's important to know that not QDir is obsolete but QDirModel.

  • @Sinedsem
    @Sinedsem 9 лет назад +4

    Any source code?

  • @Lukomeyan
    @Lukomeyan 8 лет назад

    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?

  • @Mohitkapoor5678
    @Mohitkapoor5678 9 лет назад

    How can I add checkboxes before each file listed in the file explorer view?

  • @LITTLESTUDY
    @LITTLESTUDY 6 лет назад

    wow~

  • @Manas-co8wl
    @Manas-co8wl 5 лет назад +1

    While this was interesting and informative, it seems impractical to divide up the models like this

  • @LancelotViola-l4x
    @LancelotViola-l4x 3 месяца назад

    Kellie Spring