[Qt-interest] General problem with selection in QAbstractItemView classes (QListXXX QTreeXXX etc)

Pritam Ghanghas pritam_ghanghas at infosys.com
Wed Jun 29 15:49:41 CEST 2011


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.


> I can understand such behaviour in case when item is checkable and mouse is 
> inside checkbox (so we cannot trigger such change because user can move mouse 
> and release it ... checkbox shouldn't be updated...that works correct), but 
> simple selection is wrong, because selection is updated when mouse is released 
> and that's too late (it's already selected *visually* by mousepress).
> 
> IMO, if user see selected item on the screen , our item data should be already 
> updated.
> 
> Maybe I should use QTreeView event filter not viewport ? 
> 
> Any clues / comments ? Should I open an issue about this ?
> 
> zeljko
> 
> 
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest


**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely 
for the use of the addressee(s). If you are not the intended recipient, please 
notify the sender by e-mail and delete the original message. Further, you are not 
to copy, disclose, or distribute this e-mail or its contents to any other person and 
any such actions are unlawful. This e-mail may contain viruses. Infosys has taken 
every reasonable precaution to minimize this risk, but is not liable for any damage 
you may sustain as a result of any virus in this e-mail. You should carry out your 
own virus checks before opening the e-mail or attachment. Infosys reserves the 
right to monitor and review the content of all messages sent to or from this e-mail 
address. Messages sent to or from this e-mail address may be stored on the 
Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***



More information about the Qt-interest-old mailing list