Dear all,
I seek your help in this problem which I am stucked in.
I have an icon which when I pressed it, I will create an object of it, named as iconObj. But how do I drag this newly created object? Is it possible to do this in QML? I have error when I set the drag.target: iconObj.
Image {
id: icon
width: 64
height: 64
source: "liverbird.gif"
MouseArea {
id: liverbirdMouseArea
anchors.fill: parent
width: 64
height: 64
drag.target: parent
drag.axis: Drag.XandYAxis
onPressed: {
var iconObj = Qt.createComponent("icon.qml");
iconObj.createObject(parent);
}
}
}
Image {
id: icon
width: 64
height: 64
source: "liverbird.gif"
MouseArea {
id: liverbirdMouseArea
anchors.fill: parent
width: 64
height: 64
drag.target: parent
drag.axis: Drag.XandYAxis
onPressed: {
var iconObj = Qt.createComponent("icon.qml");
iconObj.createObject(parent);
}
}
}
To copy to clipboard, switch view to plain text mode
Thank you for your kind help.
Added after 1 38 minutes:
Is it possible to pass QMouseEvent from qml into c++?
I tried in my qml calling a c++ function cc.mousePressEvent(mouse, iconObj);
MouseArea {
id: liverbirdMouseArea
anchors.fill: parent
width: 64
height: 64
onPressed: {
var iconObj = Qt.createComponent("icon.qml");
iconObj.createObject(parent);
cc.mousePressEvent(mouse, iconObj);
}
MouseArea {
id: liverbirdMouseArea
anchors.fill: parent
width: 64
height: 64
onPressed: {
var iconObj = Qt.createComponent("icon.qml");
iconObj.createObject(parent);
cc.mousePressEvent(mouse, iconObj);
}
To copy to clipboard, switch view to plain text mode
and my c++ function is declared as follows
{
}
void cc::mousePressEvent(QMouseEvent *event, QWidget *object)
{
QDrag *drag = new QDrag(object);
}
To copy to clipboard, switch view to plain text mode
but I get this error
Error: Unknown method parameter type: QMouseEvent*
Bookmarks