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:

    @file0.jpg
    file1.jpg
    file2.jpg
    ...@

    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,
    http://img20.imageshack.us/img20/2613/desired.png

    and here is what I have with QTreeView:

    http://img822.imageshack.us/img822/7787/minep.png


Log in to reply
 

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