Results 1 to 5 of 5

Thread: TransposeProxy-based filtering problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2006
    Location
    Madison, WI USA
    Posts
    153
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    35
    Thanked 1 Time in 1 Post

    Default Re: TransposeProxy-based filtering problem

    I have been able to remove the unwanted header values from the rows (0-15) in the tree view. Unforunately those rows remain empty instead of being filled with the filtered values.

    I have also found that the data() function can get both the header values AND data values.
    Qt Code:
    1. QVariant PropInspectProxyModel::data( const QModelIndex& index, int role ) const
    2. {
    3. QModelIndex source_index = mapToSource( index );
    4. if ( index.isValid() && !source_index.isValid() )
    5. return QVariant();
    6.  
    7. ///////////////////////////////////////////////////////////////////////////
    8. // How do I know when to get the header data vs. getting the data values???
    9.  
    10. // Get the Property header string
    11. QVariant vHdr = sourceModel()->headerData( index.row(), Qt::Horizontal, role );
    12.  
    13. // Get the data values
    14. QVariant v = sourceModel()->data( source_index, role );
    15.  
    16. return v;
    17. }
    To copy to clipboard, switch view to plain text mode 
    Two unresolved issues remain:
    1. How can I get my headers to fill rows 0-9 instead of 16-25?
    2. How do I know when to get header values or data values in the data() override function?
    Examples
    1. HeadersHeadersOnly..JPG
    2. DataDataOnly..JPG

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: TransposeProxy-based filtering problem

    What does rowCount() on the proxy model return? It should be the number of rows for the given parent index left after the filter is applied. Similarly for the columnCount(). If this is not the case then look at your filter implementations. Is there a hierarchy in the model... are all parent model indexes invalid or not?

    When a request is made on the filtered side of the model via data() you need to map the row number to the base model row e.g. proxy row 0 maps to row 16 in the source, 1 to 17, etc. mapToSource() should do this and mapFromSource() should do the inverse. I would have thought the default proxy implementation does this for you and you should not need to reimplement these.

    The view should never call data() to retrieve headers, that's what headerData() is for. The proxy default implementation should also be returning the header data from the base model for rows/columns that get past the filter.

Similar Threads

  1. QCA based application deployment problem
    By npclaudiu in forum Installation and Deployment
    Replies: 1
    Last Post: 14th May 2010, 11:10
  2. Qwt based project compile problem
    By MarkoSan in forum Qwt
    Replies: 0
    Last Post: 28th September 2009, 16:08
  3. Filtering QSqlQueryModel
    By mourad in forum Qt Programming
    Replies: 4
    Last Post: 2nd August 2009, 10:32
  4. Filtering a TreeWidget
    By soul_rebel in forum Qt Programming
    Replies: 6
    Last Post: 26th January 2008, 21:08
  5. processevents, filtering events
    By sreedhar in forum Qt Programming
    Replies: 1
    Last Post: 24th June 2006, 23:49

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.