Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. button click goes through the items ..
Forum Updated to NodeBB v4.3 + New Features

button click goes through the items ..

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 2 Posters 251 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ODБOïO Offline
    ODБOïO Offline
    ODБOï
    wrote on last edited by
    #1

    hi,

    Can please someone help me to understand and solve this issue ?

    import QtQuick 2.12
    import QtQuick.Window 2.12
    import QtQuick.Controls 2.12
    import QtQuick.Layouts 1.12
    
    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
        MouseArea{
            anchors.fill: parent
            onClicked: {
                console.log("main area clicked")
            }
        }
        Rectangle{  // click this rectangle will output "main area clicked"
            anchors.centerIn: parent
            height: parent.height *0.8
            width: parent.width *0.8
            color : "orange"
            RowLayout{
                anchors.fill: parent
                spacing: 30
                Button{
                    Layout.fillHeight: true
                    Layout.fillWidth: true
                    text: "clickme"
                    onClicked: {
                        console.log("btn 1 click")
                    }
                }
                Button{ // click this disabled Button will output "main area clicked"
                    Layout.fillHeight: true
                    Layout.fillWidth: true
                    text: "clickme"
                    enabled: false
                    onClicked: {
                        console.log("btn 2 click")
                    }
                }
            }
        }
    }
    
    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Rectangle is transparent to mouse events, so it lets your click through. Add a mouse area inside it to stop the event from propagating.

      Disabled button - same story, it's disabled so it will likely pass the event further.

      I haven't tested this, so it's a bit of a guess.

      (Z(:^

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved