Results 1 to 1 of 1

Thread: setCurrentIndex() doesn't display cursor(bounding rect)

  1. #1
    Join Date
    Sep 2008
    Posts
    25
    Thanks
    3
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default setCurrentIndex() doesn't display cursor(bounding rect)

    I sublcass QTreeView and QStandartItemModel to display some data. The data is displayed as a list with two columns in QTreeView.
    QTreeView has such properties in constructor:
    Qt Code:
    1. // set TreeView properties
    2. setRootIsDecorated(false);
    3. setSelectionBehavior(QAbstractItemView::SelectRows);
    4. setSelectionMode(QAbstractItemView::NoSelection);
    5.  
    6. setEditTriggers(NoEditTriggers);
    7. setAllColumnsShowFocus(true);
    8. setSortingEnabled(true);
    9.  
    10. // set header properties
    11. header()->setStretchLastSection(true);
    12. header()->setSortIndicator(0, Qt::AscendingOrder);
    13. header()->setSortIndicatorShown(true);
    14. header()->setClickable(true);
    To copy to clipboard, switch view to plain text mode 

    The problem rises when the model updates itself end after that I try to set a current item programmatically. I use setCurrentIndex() to set it. setCurrentIndex() works fine but it doesn't show the focus/cursor (look at attachment picture to understand what I mean). It is the rect around current item.
    I pass a QPersistentModelIndex to setCurrentIndex() and check it.
    I've debugged setCurrentIndex(). QTreeView::visualRect() fails to set d->pressedPosition because of invalid index. But how can this be possible, the index is checked and is valid?
    Do anybody know how to fix that?
    Attached Images Attached Images

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.