[Qt-interest] General problem with selection in QAbstractItemView classes (QListXXX QTreeXXX etc)
Zeljko
zeljko at holobit.net
Thu Jun 30 09:42:58 CEST 2011
Pritam Ghanghas wrote:
> On Wed, 2011-06-29 at 17:25 +0530, Zeljko wrote:
>> Hi,
>> Just found an interesting problem with selection behaviour inside
>> QAbstractItemView classes (no matter which class it is QListView,
>> QListWidget, QTreeView, QTreeWidget ... even created my own QTreeView with
>> QStandardItemModel and my QItemSelectionModel etc etc). I've used selection
>> signals for such purpose but now I need accurate information (need it for my
>> QTreView + QStandardItemModel) when mouse is pressed so:
>>
>> 1.MousePress event in itemView viewport
>> 2.You can clearly see that item is selected (colored blue, focus rect around
>> it ...)
>> 3.Ask that item is it selected ... NO ?!?
>> 4.Ok ask Selection model about that selection ? NO ?!?
>>
>> 5.MouseRelease .... ahh item says that's selected :( ...it's too late.
>>
>> That's pretty nasty. You can see selected item but code says that item isn't
>> selected :(
>
> May be two layered selection model has something to do with it.
> Take a look
> http://doc.qt.nokia.com/latest/qitemselectionmodel.html#details
>
> I am not sure though.
huh...seem that it can work by calling
QItemSelectionModel::select(IndexUnderMouse,Select || Current), but probably
this will broken multiselections ...
It updates item selected state.
z.
More information about the Qt-interest-old
mailing list