Drag a copy of an item to Droparea
-
I've been attempting to implement something similar to the QtQuick example drag and drop:
http://doc-snapshot.qt-project.org/5.0/qtquick/quick-draganddrop.htmlIt seems quite straightforward to drag items from a list to a Droparea and the example is almost what I want to do. In my case, however, I need to keep the original list intact (i.e. make a copy of the original list item to put in the Droparea). I'm assuming this line in DragTile.qml:
@
onReleased: parent = tile.Drag.target !== null ? tile.Drag.target : root
@becomes something more like:
@
onReleased: {
if(tile.Drag.target !== null ) { cppModel.copyItem(tile.Drag.target) }
}
@Is this reasonable?
Also, when in the process of dragging, can I leave the list item in place and drag some sort of graphical replacement for it? If so, how would I do this?
-
It's C.
Is somethink like this:
@ onReleased: {
if(tile.Drag.target !== null ) { cppModel.copyItem(tile.Drag.target) }
}
else
{
root;
}@If root makes something. If not, is like you say.
-
So that works for adding the item to the C++ model. I still am not sure how to drag a "copy" of the object to add to the model.
-
OK, so I found an example that does essentially what I want:
http://qt-project.org/doc/qt-4.8/declarative-toys-dynamicscene.html (Specifically the dragging and dropping of scene elements)
The only real issue is that it's Qt 4.8 and it's not especially easy to implement that same behavior in my application because I'm actually dragging it to a DropArea that's a view which will rearrange items rather than simply allowing the item to drop in an arbitrary location.
It seems like this is a pretty basic case that should be handled by QML in Qt 5.0. Is this just not a case that is meant to be handled by the base QML elements?
Any guidance would be appreciated.
-
@stevenhurd Hello,
I'm facing the same issue here. Have you found any way to drag a copy through Drag and DropArea mechanism.
Any help will be appreciated.
Thank you. -
Hmm, yeah, I actually did get it working but that was a long time ago and I haven't looked at the code much lately. You're welcome to browse through it though to see what you can find: "https://github.com/stevenchurd/EvalWriter/tree/beta/code/gui/qml":https://github.com/stevenchurd/EvalWriter/tree/beta/code/gui/qml
I ended up doing it with the help of javascript if I remember correctly. Maybe start with this and see if it helps: "https://github.com/stevenchurd/EvalWriter/blob/beta/code/gui/qml/criteriaItemRowCreation.js":https://github.com/stevenchurd/EvalWriter/blob/beta/code/gui/qml/criteriaItemRowCreation.js
-
Thank you I will take a look and try to figure it out.
Thank you again.