Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Having a "pass-through" MouseArea on a WebEngineView



  • I need to track whether the user has recently moved the mouse in my app. This app contains a WebEngineView. I currently have this code in the middle of my app; I've added imports to make it a complete program:

    import QtQuick 2.12
    import QtWebEngine 1.8
    
    WebEngineView {
        url: "https://example.com"
    
        MouseArea {
            anchors.fill: parent
            z: parent.z + 1
            hoverEnabled: true
            propagateComposedEvents: true
    
            onPositionChanged: {
                mouse.accepted = false
                logoutTimer.restart()
            }
    
            onPressed: {
                mouse.accepted = false
                logoutTimer.restart()
            }
    
            onReleased: {
                mouse.accepted = false
                logoutTimer.restart()
            }
    
            onHoveredChanged: {
                mouse.accepted = false
                logoutTimer.restart()
            }
        }
    }
    

    Unfortunately, this only propogates click events to the WebEngineView, which removes any possibility of hover effects or changing the cursor to a pointing-hand-link-style cursor. I understand that hover events aren't affected by changing mouse.accepted.

    I'm on Qt 5.15.2 on openSUSE Tumbleweed.


Log in to reply