[Qt-interest] How to show decorations only during dragging in custom QTableView/Model?

Robert Hairgrove evorgriahr at hispeed.com
Sat Mar 28 12:31:10 CET 2009


I have a timetable for student lessons which has drag & drop enabled to 
move lessons around on the table view. This works fine, as long as I am 
only displaying text data in response to the model's data() event when 
the role argument is Qt::DisplayRole. So far so good...

What I would like to do additionally is to display a little green icon 
in the available (empty) lesson cells for the student whose currently 
assigned lesson is about to be dragged. That way, the user can see what 
possibilities there are for alternate lesson scheduling.  After the 
lesson has been dropped in the new cell, the icons should disappear.

It seems like once dragging has started, it is too late to display 
anything in any of the other cells.  Which event would be the best place 
to do it -- onMouseDown, perhaps? I am having trouble deciphering the 
correct order of events.

Thanks!



More information about the Qt-interest-old mailing list