How to get mouse position when handling SplitView
Unsolved
QML and Qt Quick
-
I make my own split view for my purpose.
import QtQuick 2 import QtQuick.Layouts Item { id: splitView RowLayout { anchors.fill: parent spacing: 0 Rectangle { Layout.fillWidth: true; Layout.fillHeight: true id: leftItem color: "red" } ToolSeparator { Layout.fillHeight: true id: handle property int leftLimit: 0 property int rightLimit: splitView.width MouseArea { anchors.fill: parent id: handleMouseArea acceptedButtons: Qt.LeftButton cursorShape: Qt.SplitHCursor onMouseXChanged: { /* Mouse position in the SplitView*/ var pos = mapToItem(splitView, mouse.x, mouse.y) if (pressed) { var xPos = pos.x - handle.width / 2 if (handle.leftLimit < xPos && xPos + handle.width < handle.rightLimit) { /* This is basic functionality of SplitView */ handle.x = xPos leftItem.width = handle.x rightItem.x = handle.x + handle.width rightItem.width = splitView.width - leftItem.width - handle.width } } } } } Rectangle { Layout.fillWidth: true; Layout.fillHeight: true id: rightItem color: "blue" } } }
any better?