views:

61

answers:

1

Hi,

I just want to clarify, weather the feature is present or not in Qt. The scenario is like this,

I have a list view with items, I want to place the icon to the listview when the item is selected.

The selection I mean is, first time when I click item should be selected, next time if I click the same item then it should display some icon. Please note It is not the double click. again if do select some other item same feature should continue

So is there any feature which handles this feature by default, any property or flag which I need to set to listview to behave like this or manual implementation Is required for this.

A: 

No problem (: Now I understand what you mean... So if you click on an item it should be selected (for example highlighted in blue) and then when you click on this item again, an icon should be displayed.

I can't think of a regualar way to do this, there is no such flag or something.

The easiest way I can think of would be to store the index in a QList when you select it. And when you deselect it, you delete the index from the list. SO, when you click on an item you can check if it is in that list and if so you can display your icon.

Another way would be to create your own type of QModelIndex. Everytime, this index is selected, you set a bool like is_already_selected on true. When clicking on this item again you check this bool and then decide whether an icon should be displayed or not.

For further information, see: QListView, QAbstractItemView::currentIndex, QModelIndex

Exa
oh.. ok thank you.. i thought some alternate direct method is there for it, but :(... any way ill try ur technique.thanks lot :)
Shadow