⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)

Subclassing QAbstractProxyModel to work with QFileDialog

  • Hello,
    I would like to create a custom QFileDialog that has a special behaviour:

    I'd like the files in the directory to be represented as 1 file if they belong to such a sequence:


    would be represented as only 1 item: @file#.jpg@

    Also whenever the user would select file#.jpg I'd like the file dialog to return all the associated file names.

    After reading all the Qt documentation I find it really hard to pull-off.
    I figured I'd have to subclass @QAbstractProxyModel@ and call @QFileDialog::setProxyModel@ but I don't really know what to do with the @QAbstractProxyModel@
    Does anybody have any idea on how to get started on this?

  • As far as model is concerned you will need to implement rowCount(), data(), mapToSource() and mapFromSource().

    Also you will need to have a custom QFileDialog because it has to return multiple files when selected.

  • Do you mean deriving QFileDialog or make my own file dialog?
    In the later case, how would you custom the view so it has a behaviour as such :

    • when the user clicks the directory, it show the content of the directory, it does not unfold an item in a QtreeView

    Here is a picture of what I'd like it to be,

    and here is what I have with QTreeView:


Log in to reply