Qt 如何在QQuickPaintedItem中选择区域
我想为我的qml图像编辑器构建一个选择工具 对于这一点,我正在寻找类似的函数,如a中的Qt 如何在QQuickPaintedItem中选择区域,qt,qml,selection,image-editing,Qt,Qml,Selection,Image Editing,我想为我的qml图像编辑器构建一个选择工具 对于这一点,我正在寻找类似的函数,如a中的setselectedrea。 有人能解决这个问题吗 问候 编辑:也许我可以为我的选择工具编写一个插件,扩展QQuickItem并使用openGL绘制一个QPolygon。您需要自己实现选择 您可以创建MouseArea来跟踪鼠标活动并相应地更新选定的rect。我的意思是这样的: DocumentViewer { // Your QQuickPaintedItem id: viewer Mous
setselectedrea
。
有人能解决这个问题吗
问候
编辑:也许我可以为我的选择工具编写一个插件,扩展
QQuickItem
并使用openGL绘制一个QPolygon。您需要自己实现选择
您可以创建MouseArea来跟踪鼠标活动并相应地更新选定的rect。我的意思是这样的:
DocumentViewer { // Your QQuickPaintedItem
id: viewer
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton
property real originX: 0
property real originY: 0
onPressed: {
originX = mouse.x
originY = mouse.y
}
onPositionChanged: {
var width = mouse.x - originX
var height = mouse.y - originY
viewer.selectionRect = Qt.rect(originX, originY, width, height)
}
}
}
然后,您将能够在查看器的selectionRect
属性设置器中更新并绘制选择矩形