How to highlight (or) draw on drop target item, when a drag is active??
Greetings!
I have a treeview and all its columns are delegated.
Requirement:- When I drag a row and try to drop it to another row, I want to show some indication in target row either by drawing a rectangle (highlighting the target row).
In the constructor of the delegate, the event filter has been installed.
QTreeView* pTreeView = dynamic_cast<QTreeView*>(parent); //parent is treeview
pTreeView->viewport()->installEventFilter(this);
And in the eventFilter of this delegate (derived from QStyledItemDelegate), I could catch the MouseMove (or) DragMove event. Also I can get the mouse position and the index on which the cursor is present.
Issue:- With the mouse position, I am trying to draw a rectangle in the paint function. BUT WHEN THE DRAG IS ACTIVE, THE PAINT METHOD IS NOT GETTING CALLED.
It would be great, if somebody throw some light on this issue... Why the paint is not getting called? Is there any other approach to tackle this issue.
P.S: I vastly searched this forum. Two of them had exact issue, but no answer for this.
Regards
Re: How to highlight (or) draw on drop target item, when a drag is active??
Check the Puzzle example in Qt Demos.
Qt Demos \ Item Views \ Puzzle.
It has similar working to your requirement.
Re: How to highlight (or) draw on drop target item, when a drag is active??
I checked that, before I raised question in this forum.
That example is demonstrated in a widget. The drag and paint events are there in the widget itself.
In my scenrio, I have a treeview and all the columns are delegated. When a tree item is dragged, behind the scene the paint method in delegate is not getting called. Once I drop it, the paint is called...
Re: How to highlight (or) draw on drop target item, when a drag is active??
I found some useful thread which helps me to attack my problem.
http://www.qtcentre.org/threads/2829...drop-revisited
Basically we need to emit layoutChanged signal in dropMoveEvent.