[Interest] Getting QTreeView item click offset for DnD

Jason H scorp1us at yahoo.com
Tue Apr 17 16:54:00 CEST 2012


Well I am confused about how the view works.
I'm using QStandardItems, so whatever Qt does with those... I can't find documentation anywhere...



________________________________
 From: André Somers <andre at familiesomers.nl>
To: interest at qt-project.org 
Sent: Tuesday, April 17, 2012 10:40 AM
Subject: Re: [Interest] Getting QTreeView item click offset for DnD
 

Op 17-4-2012 16:35, Jason H schreef: 
I need to repeat this. I'm still lost.
>here is my code (child is always NULL):
>
>voidDataPointTreeView::mousePressEvent(QMouseEvent*event) 
>{
>QTreeView::mousePressEvent(event);
>QModelIndexmi=indexAt(event->pos());
>QWidget*child=indexWidget(mi);
>//QWidget*child=static_cast<QWidget*>(childAt(event->pos()));
>if(!child)
>return;
>m_dragOffset=event->pos()-child->pos();
>}
>
>
Are you even using widgets for your items? I mean: do you call setIndexWidget anywhere? If not, perhaps you should check what indexWidget() actually returns?

André





>________________________________
> From: Jason H <scorp1us at yahoo.com>
>To: Interests Qt <interest at qt-project.org> 
>Sent: Friday, April 13, 2012 12:04 PM
>Subject: [Interest] Getting QTreeView item click offset for DnD
> 
>
>I need to drag model items from a QTreeView to a widget and make the item appear in the widget at the right spot.
>I have it working except that the drop is not exact. It is off by where the user clicked in the QStandardItem.
>I need to figure out how to get that click offset (i.e. QPoint(50,10)) and factor that into the drop location (i.e move(event->pos()-clickOffset);)
>
>
>What do I need to do to get that click offset inside the QTrreeView?
>
>
>Thanks.
>
>
>_______________________________________________
>Interest mailing list
>Interest at qt-project.org
>http://lists.qt-project.org/mailman/listinfo/interest
>
>
>
>
>
>_______________________________________________
Interest mailing list Interest at qt-project.org http://lists.qt-project.org/mailman/listinfo/interest 

_______________________________________________
Interest mailing list
Interest at qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120417/a46098e7/attachment.html>


More information about the Interest mailing list