Results 1 to 3 of 3

Thread: QAbstractProxyModel for 'Group By' -- works but arrow keys don't !?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2009
    Posts
    57
    Thanks
    7
    Thanked 5 Times in 4 Posts

    Default Re: QAbstractProxyModel for 'Group By' -- works but arrow keys don't !?

    I should have mentioned that the arrow keys don't move up and down in a QTreeView when this proxymodel is between the view and the source sqltable.

    Cheers,
    Mark

  2. #2
    Join Date
    Sep 2009
    Posts
    57
    Thanks
    7
    Thanked 5 Times in 4 Posts

    Default Re: QAbstractProxyModel for 'Group By' -- works but arrow keys don't !?

    Fixed it ha!

    Because I have a virtual column in column zero, but mapToSource returns an invalid QModelIndex for column zero (because it doesn't exist in the source) then the flags for column zero are empty -- and makes it non-selectable.

    If I provide my own version of ::flags() and make it selectable the arrow keys spring into life. yay!

    here is the bit of code I needed to add, I make the groupby's unselectable since they are just 'headings' not data (if that makes any sense).

    Qt Code:
    1. Qt::ItemFlags flags ( const QModelIndex & index ) const {
    2. if (index.internalPointer() == NULL) {
    3. return Qt::ItemIsEnabled;
    4. } else {
    5. return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
    6. }
    7. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Detect Arrow Keys
    By Ebonair in forum Qt Programming
    Replies: 4
    Last Post: 1st October 2010, 03:55
  2. Replies: 1
    Last Post: 6th July 2009, 13:48
  3. QAbstractProxyModel to do a Tree
    By xgoan in forum Qt Programming
    Replies: 3
    Last Post: 18th November 2008, 17:31
  4. Help with QAbstractProxyModel
    By killerwookie99 in forum Qt Programming
    Replies: 9
    Last Post: 12th September 2008, 22:13
  5. How can I associate arrow keys?
    By Mariane in forum Newbie
    Replies: 2
    Last Post: 20th January 2006, 18:31

Tags for this Thread

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.