使图形项与鼠标光标保持在一起
Make graphical item stay together with the mouse cursor
我有一个图形项,其中 x 和 y 绑定到鼠标位置。当我快速移动鼠标时,项目会跟随光标,平滑地朝着当前位置移动。我希望它始终保持与光标相同的位置。可能吗?
当前代码:
Item{
width: 800; height: 600;
Rectangle{
width: 50; height: 50; color: "red";
x: area.mouseX;
y: area.mouseY;
}
MouseArea{
id: area
anchors.fill: parent
hoverEnable: true
}
}
部分解决方案...
我在图形项中包含了一个光标图片,并使真正的鼠标光标不可见(cursorShape: Qt.BlankCursor
)。
这个假光标对用户输入的延迟与我在绑定项目中注意到的一样,但至少现在所有部分都保持在一起。
我有一个图形项,其中 x 和 y 绑定到鼠标位置。当我快速移动鼠标时,项目会跟随光标,平滑地朝着当前位置移动。我希望它始终保持与光标相同的位置。可能吗?
当前代码:
Item{
width: 800; height: 600;
Rectangle{
width: 50; height: 50; color: "red";
x: area.mouseX;
y: area.mouseY;
}
MouseArea{
id: area
anchors.fill: parent
hoverEnable: true
}
}
部分解决方案...
我在图形项中包含了一个光标图片,并使真正的鼠标光标不可见(cursorShape: Qt.BlankCursor
)。
这个假光标对用户输入的延迟与我在绑定项目中注意到的一样,但至少现在所有部分都保持在一起。