标题:Drag & Drop 过程中,源Item被释放(析构)程序出错
作者:jj200602
日期:2018-01-02 22:32
内容:
如题。 现在拖动的Item 在放到Drop区前,动态地被析构了,必然会引起程序崩溃。
是我用法不对还是有什么方案可以解决的?
#1 [jj200602 01-02 22:40]
import QtQuick 2.0
import QtQuick.Controls 1.3
Rectangle {
id: container
property int counter: 1
width: 600; height: 600
Timer{
interval: 10000
repeat: true
running: true
onTriggered: container.counter++;
}
Repeater{
model: container.counter
Rectangle {
id: iddragblock
width: 50; height: 50
y: 54 * index
x: 54 * index
color: "red"
Drag.active: idmousearea.drag.active
Drag.dragType: Drag.Automatic
MouseArea {
id:idmousearea
anchors.fill: parent
drag.target: iddragblock
}
}
}
}
试验代码如上。只要使用了Automatic, 触 ..
#2 [maxlogo 01-03 22:51]
When using Drag.Automatic you should also define mimeData and bind the active property to the active property of MouseArea : MouseArea::drag.active