Results 1 to 3 of 3

Thread: [QT4] Selecting indices from a QTreeView - multiple duplicates

  1. #1
    Join Date
    Feb 2006
    Location
    USA
    Posts
    142
    Thanks
    24
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default [QT4] Selecting indices from a QTreeView - multiple duplicates

    Hello... I've got some code that's starting to make me pull out my hair.

    I'm doing the following with my tree view to get the indices that have been selected:
    Qt Code:
    1. QList <QModelIndex> myList = ui.myTreeView->selectionModel()->selectedIndexes();
    To copy to clipboard, switch view to plain text mode 

    According to the docs, selectedIndexes() returns the selected indices from the view with no duplicates. In my case, it returns indices equal to the total indices in the tree, all of them identical (the one index that I had selected). This is really starting to get to me.

    I'm using QT 4.0.1 on this machine (Yes, I'm aware that 4.1.1 is out - I'd have to re-compile a new set of libraries with similar arguments to ./configure that were not trivial to get 4.1.1 on this machine).

    Any ideas? Thanks.
    Life without passion is death in disguise

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: [QT4] Selecting indices from a QTreeView - multiple duplicates

    Seems to work fine for me with Qt 4.1.1 on WinXP.
    Are you aware that for a multi column tree each column in a row is represented by a separate index in the selection list?

  3. The following user says thank you to jpn for this useful post:

    KShots (10th March 2006)

  4. #3
    Join Date
    Feb 2006
    Location
    USA
    Posts
    142
    Thanks
    24
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: [QT4] Selecting indices from a QTreeView - multiple duplicates

    Aha, I think you hit the nail on the head. You're a genius.

    No, I was not aware of that, but now it all makes sense. Thanks!
    Life without passion is death in disguise

Similar Threads

  1. [QT4] QTreeView and rows with multiple lines
    By KShots in forum Qt Programming
    Replies: 8
    Last Post: 30th March 2006, 19:47

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.