Results 1 to 2 of 2

Thread: QTreeView selection strangeness

  1. #1
    Join Date
    Apr 2009
    Posts
    13
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTreeView selection strangeness

    Hi,

    I've QTreeView + custom Model that returns Qt::ItemIsSelectable flag only for some of the items. View selection mode and behaviour are set to QAbstractItemView::ExtendedSelection & QAbstractItemView::SelectRows.

    Clicking on item that hasn't got Qt::ItemIsSelectable flag set I get selectionChanged(..) signal from the SelectionModel.

    What makes this confusing is that QItemSelectionModel::selectedIndexes() and QItemSelectionModel::selectedRows() returns at this point empty list but QItemSelectionModel::hasSelection() returns 'true'. This same behaviour persists even if I call the functions in other places later and haven't touched the selections in any way since the selectionChanged(..)

    Is this how it's supposed to work or is there some problem in my code (probably model.cpp) ? I've attached src of small test program that shows the behaviour. By pressing F1 it shows current selection info. Anyone else get the same strange result ?

    Qt source didn't give any positive answers to me and reading Qt docs doesn't clearly tell that selectedRows() and hasSelection() somehow mean different set of selections...

    Im running Qt 4.5.3 on linux but I remember this problem(?) being present also in earlier version(s).

    Thanks
    Attached Files Attached Files

  2. #2
    Join Date
    Apr 2009
    Posts
    13
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTreeView selection strangeness

    Well noticed another problem in the app I posted.

    If I first select all items in the View and then start ctrl-deselecting rows, QItemSelectionModel::rowsSelected() returns wrong values: at times it decreases by more than one and at other times it can even increase. However QItemSelectionModel::selectedIndexes() does decrease always by 2 which is correct because there are only 2 columns in the model.

    So after that I slightly modified the Qt SimpleTreeModel-example (just to get input when selections change) and noticed the same problem even then...

    Anyone willing to test out the code I posted and report if this same thing happen for you ? I wouldn't want to start blaming qt quite yet

Similar Threads

  1. [SOLVED] QTreeView drawing selection with icons
    By Timewarp in forum Qt Programming
    Replies: 7
    Last Post: 7th February 2013, 07:52
  2. Custom selection actions in QTreeView
    By iraytrace in forum Qt Programming
    Replies: 2
    Last Post: 11th November 2009, 20:51
  3. Selection row in QtreeView
    By visor_ua in forum Qt Programming
    Replies: 2
    Last Post: 15th June 2008, 22:31
  4. Replies: 1
    Last Post: 28th February 2007, 08:34
  5. Qtreeview selection highlighted problem?
    By thefisher in forum Qt Programming
    Replies: 4
    Last Post: 24th November 2006, 09:50

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.