PDA

View Full Version : How to reimplement QTreeWidget::dropEvent?



adrianhill102
22nd October 2010, 15:02
I need to override the dropEvent() method in QTreeWidget to give me some additional control over drag and drop. More specifically I want to apply a set of rules to prevent certain items being made children of other items. (E.g. list items containing text 'a' cannot be dragged underneath list items containing text 'b').

I have started by copying the contents of qtreewidget::dropEvent() into an overidden version of dropEvent() but this calls 'dropOn' which would also have to be pulled in and I fear that I'm starting to suck in the whole of QT!

My questions are as follows:

Am I taking the correct approach?

If not, what are the alternatives?

If yes, can you give any advise on including the existing functionality in my overidden version of dropEvent()?

Thank you.

Adrian.

wysota
22nd October 2010, 15:41
Do it in dragMoveEvent() and not dropEvent(), then it'll be very easy.