我想为我的qml图像编辑器构建一个选择工具。
为此,我正在寻找类似于setSelectedArea的QGraphicsScene函数。有人能解决这个问题吗?
问候
编辑:,也许我可以为我的选择工具编写一个插件,它扩展了QQuickItem,用openGL绘制了一个QPolygon。
发布于 2014-11-29 13:48:34
你需要自己实现选择。
您可以创建跟踪鼠标活动的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属性设置器中绘制选择矩形。
https://stackoverflow.com/questions/27016097
复制相似问题