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. Ignore MouseArea onClicked event for transparent areas of parent Qt Quick Image
Forum Updated to NodeBB v4.3 + New Features

Ignore MouseArea onClicked event for transparent areas of parent Qt Quick Image

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 370 Views
  • 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.
  • J Offline
    J Offline
    jars121
    wrote on last edited by
    #1

    I've found several similar questions pertaining to this topic, but haven't pieced together a workable solution as of yet. I've got non-rectangular Qt Quick Images, each with a child MouseArea. The current onClicked event registers clicks of the parent Image in areas of transparency, which I would like to ignore. Is there a QML-only solution to do this? Would a QML-only solution be adviseable, or should the transparency determination be done in c++?

    Some pseudocode as an example:

    Image {
        id: testImage
        x: 200
        y: 100
        width: 100
        height: 150
        fillMode: Image.PreserveAspectFit
        source: "TestImage.svg"
    
        MouseArea {
            id: testMouseArea
            anchors.fill: parent
            onClicked: {
                //if alpha of (mouseX, mouseY) > 0 {
                    //DO STUFF
                //}
            }
        }
    }
    

    My understanding is that getImageData() won't work for this purpose, so it may not be possible to determine the alpha level of the parent Image at the (mouseX, mouseY) coordinates in QML directly.

    1 Reply Last reply
    0

    • Login

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