[Qt-interest] prevent a drop in QTreeWidget
Graham Labdon
Graham.Labdon at avalonsciences.com
Fri May 27 15:21:33 CEST 2011
I don't have a model tho
-----Original Message-----
From: Bo Thorsen [mailto:bo at sonofthor.dk] On Behalf Of Bo Thorsen
Sent: 27 May 2011 14:02
To: Graham Labdon
Cc: qt-interest at qt.nokia.com
Subject: Re: [Qt-interest] prevent a drop in QTreeWidget
Den 27-05-2011 10:03, Graham Labdon skrev:
> Hi
> Can someone advise me how to prevent a drop being accepted in certain circumstances in a QTreeWidget?
> I have derived a class from QTreeWidget and have reimplemented the DropEvent method.
> How do I get the information that tells me where the item is being dropped so I can tell whether or not the drop should be allowed?
I saw that you already got something working. But it's actually the
wrong direction you are going in.
Don't touch the drop code on QTreeWidget. Instead, handle this in the
model. You should read the entire section on using drag and drop with
the model/view classes.
The method you need here is QAbstractItemModel::dropMimeData(...).
Override that instead of the view.
Bo Thorsen,
Fionia Software.
--
Expert Qt and C++ developer for hire
Contact me if you need expert Qt help
http://www.fioniasoftware.dk
More information about the Qt-interest-old
mailing list