[Qt-interest] prevent a drop in QTreeWidget
Bo Thorsen
bo at fioniasoftware.dk
Fri May 27 16:35:19 CEST 2011
Den 27-05-2011 15:21, Graham Labdon skrev:
> I don't have a model tho
You always have a model :)
If you are using the standard item model, you should consider switching
over. They are fun tools to figure out how to get something quickly in a
view, but they are IMO not for production code.
Bo.
> -----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.
>
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