0
votes

I'd like to add a pressAndHold handler to tabs created by a TabView. If I attach such a handler to the component that the TabView generates the tab from, then the tab no longer works, because the press doesn't get to the underlying tab. Setting propagateComposedEvents doesn't help, because press isn't a composed event. I tried rolling my own pressAndHold system using a timer, and handling press and release, but that still prevents the pressed signal from getting to the underlying tab. I tried clearing mouse.accepted in my press handler, but then I don't get the release signal, because the MouseArea assumes I couldn't be interested in it if I didn't accept the press. So I'm stumped.

The general question is: how do you monitor all mouse signals with a MouseArea, and possibly add behavior, without preventing them from getting through to whatever is underneath it? The more limited question is: how do you add pressAndHold to something that already handles press and/or click, but doesn't handle pressAndHold--when you don't have access to the underlying mouse handler?

1

1 Answers

0
votes

Hope that I understand your problem in the right way. You can try to put TabView into MouseArea. Anyway, It's not the best solution.

import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Controls 1.4

Window {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    MouseArea {
        anchors.fill: parent
        onPressAndHold: console.log("press")
        TabView {
            Tab {
                title: "Red"
                Rectangle { color: "red" }
            }
            Tab {
                title: "Blue"
                Rectangle { color: "blue" }
            }
            Tab {
                title: "Green"
                Rectangle { color: "green" }
            }
        }
    }
}