[Solved] List files like QFileDialog

  • Hi,

    I have the "following":http://huxi.uw.hu/hidden/Qt/got.jpg (I know, it's bad :D) view. I would like to list the files I drag and drop / browse and add to the model like "this":http://huxi.uw.hu/hidden/Qt/want.jpg (with the option to switch detailed / normal mode). I was wondering if there was an easy way to achieve this. Currently I have my own subclass of QTreeView with drag and drop (the first, really bad looking one), and I tried to look for easy solutions (like QFileSystemModel), but none of them could achive this. So my questions are:

    1: Is there an easy way to achive this view, or
    2: How could I make the view look like the one in the picture (I mean the non-detailed list of files, the detailed is easy with QTreeView I guess, but I don't know how to make QListView have multiple columns like this).

    Thanks in advance!

  • You need using QListView class
    for detailed / normal mode you can change viewMode property:

    @enum QListView::ViewMode@

    QListView::ListMode -The items are laid out using TopToBottom flow, with Small size and Static movement
    QListView::IconMode - The items are laid out using LeftToRight flow, with Large size and Free movement

  • For a detailed view, yiou need a QTreeView or a QTableView.
    QFileDialog uses a QTreeView for detailed mode and a QListView for normalMode.

    Have a look at the implementation of QFileDialog to see, how it is done

  • Vass thank you, I have no idea how I slipped over that. That solved everything :)
    Thanks Gerolf for confirming my thoughts, and I've checked QFileDialog sources too, it works and looks perfect now.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.