Results 1 to 2 of 2

Thread: customize a QSortFilterProxyModel with additional columns

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2009
    Posts
    15
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default customize a QSortFilterProxyModel with additional columns

    My final goal is to display generated information in extra columns in a custom QFileDialog. The documentation indicates that by using a custom proxy model I should be able to add columns to the proxy model and have them displayed in the QFileDialog.

    My first task was to determine the best place to gather the information and generate my custom data. My initial thought was filterAcceptsRow. I decided to start simple and just have filterAcceptsRow print out the data being displayed in the table. I was surprised to find that this method appears to only operate on folder information.

    For this test my QFileDialog I start at a folder that ONLY contains .dpx files (which, incidentally, is what my filter is set to.) I expected that by default every item would pass through here prior to only .dpx files being returned. Can anyone explain what's happening here?

    Qt Code:
    1. bool TestProxyModel::filterAcceptsRow ( int source_row, const QModelIndex &source_parent ) const
    2. {
    3. qDebug() << "&&&&entered TestProxyModel::filterAcceptsRow --> source_row is " << source_row;
    4. qDebug() << " DisplayRole[ " << source_parent.row() << ", " << source_parent.column() << " ] = " << source_parent.data( Qt::DisplayRole).toString();
    5. qDebug() << " FileNameRole[ " << source_parent.row() << ", " << source_parent.column() << " ] = " << source_parent.data( QFileSystemModel::FileNameRole ).toString();
    6. qDebug() << " FilePathRole[ " << source_parent.row() << ", " << source_parent.column() << " ] = " << source_parent.data( QFileSystemModel::FilePathRole ).toString();
    7.  
    8. qDebug() << " DisplayRole[ " << source_parent.row() << ", 1 ] = " << source_parent.sibling(source_parent.row(), 1).data( Qt::DisplayRole).toString();
    9. qDebug() << " FileNameRole[ " << source_parent.row() << ", 1 ] = " << source_parent.sibling(source_parent.row(), 1).data( QFileSystemModel::FileNameRole ).toString();
    10. qDebug() << " FilePathRole[ " << source_parent.row() << ", 1 ] = " << source_parent.sibling(source_parent.row(), 1).data( QFileSystemModel::FilePathRole ).toString();
    11.  
    12. return QSortFilterProxyModel::filterAcceptsRow( source_row, source_parent );
    13. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Nov 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Re: customize a QSortFilterProxyModel with additional columns

    I know it's been a while but did you ever solve this issue? I need to add columns for custom data as well.

Similar Threads

  1. Replies: 8
    Last Post: 14th August 2008, 15:48
  2. XCode and additional files
    By themolecule in forum Qt Programming
    Replies: 0
    Last Post: 6th May 2008, 06:57
  3. Additional classes and widgets for Qt.
    By ufo-vl in forum Qt Programming
    Replies: 4
    Last Post: 22nd July 2007, 13:51
  4. Additional QtMsgHandler information
    By bruccutler in forum Newbie
    Replies: 2
    Last Post: 23rd April 2007, 16:38
  5. Moving columns/hiding columns in QTreeView
    By yogeshm02 in forum Qt Programming
    Replies: 4
    Last Post: 14th March 2007, 16:22

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.