PDA

View Full Version : [QT4] Selecting indices from a QTreeView - multiple duplicates



KShots
10th March 2006, 17:01
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:
QList <QModelIndex> myList = ui.myTreeView->selectionModel()->selectedIndexes();

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.

jpn
10th March 2006, 17:16
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?

KShots
10th March 2006, 18:04
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!