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. Mouse area overlapping
Forum Updated to NodeBB v4.3 + New Features

Mouse area overlapping

Scheduled Pinned Locked Moved QML and Qt Quick
14 Posts 6 Posters 11.9k 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.
  • H Offline
    H Offline
    hhartz
    wrote on last edited by
    #2

    It would be great if you could include the code you've written for this so others can assist you more easily. One tip however, to 'debug' your mouse area's you can put a transparent rectangle inside so you can more easily see the hit-area they enable;

    @MouseArea {
    // ...
    Rectangle {
    anchors.fill: parent
    color: "transparent"
    border.color: "red"
    border.width: 1
    }
    }@

    --

    1 Reply Last reply
    0
    • P Offline
      P Offline
      puelocesar
      wrote on last edited by
      #3

      I'm having this problem too. Here's the code:

      @ImagemHover {
      nome: "buscar"
      anchors.horizontalCenter: bola.horizontalCenter
      anchors.bottom: bola.bottom
      anchors.bottomMargin: -20
      }

      Bola {
      id: bola
      color: "gray"
      width: 128; height: 128
      anchors.centerIn: parent
      imagem: "img/fotos/eu.jpg"

      MouseArea {
          anchors.fill: parent
          anchors.margins: -25
          hoverEnabled: true
      
          onEntered: { bola_hover = true }
          onExited: { bola_hover = false }
      }
      

      }@

      And here's the code for the ImagemHover:

      @import Qt 4.7

      Image {
      property string nome: "buscar"
      source: "img/"+ nome +"_normal.png"

      opacity: bola_hover ? 1 : 0
      Behavior on opacity { PropertyAnimation {} }
      
      Image {
          id: hover
          source: "img/"+ nome +"_hover.png"
          opacity: 0
          Behavior on opacity { PropertyAnimation {} }
      }
      
      MouseArea {
          anchors.fill: parent
          hoverEnabled: true
      
          onEntered: { hover.opacity = 1 }
          onExited: { hover.opacity = 0 }
      }
      

      }
      @

      As you can see, the ImagemHover is under Bola, so it's mouse area isn't having effect, because Bola's MouseArea is over it..

      How can I work with this overlapping problem?

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DenisKormalev
        wrote on last edited by
        #4

        puelocesar, as I know there is no solution now for overlapping mouse areas, but I think changing z-order of items will help you in your case.

        1 Reply Last reply
        0
        • P Offline
          P Offline
          puelocesar
          wrote on last edited by
          #5

          I need to change a little ImageHover logic, but now it's working. Thanks

          1 Reply Last reply
          0
          • D Offline
            D Offline
            DenisKormalev
            wrote on last edited by
            #6

            puelocesar, you've changed z-order or you have done something other? If second it will be good if you can post the solution

            1 Reply Last reply
            0
            • P Offline
              P Offline
              puelocesar
              wrote on last edited by
              #7

              My problem was: I have a circle, and when the circle mouse overs, a set of options appear above the circle.

              So, when I moused over the Circle, I set the options opacity to 1, showing them. And when I moused over one of the options, that were inside the circle, the option would change it's color to orange.

              But the mouse area's of the options and the circle were overlapping, so it wasn't working.

              The solution was to put the Circle's MouseArea under the options (z-order), and adding the logic that was only on circle's mousearea inside the options mouseareas. So the overlapping wasn't a problem anymore.

              Is this making any sense? it was very difficult to explain that without drawing :P

              1 Reply Last reply
              0
              • P Offline
                P Offline
                puelocesar
                wrote on last edited by
                #8

                Resuming, I changed the z order of the circle, and changed this on ImagemHover:

                @import Qt 4.7

                Image {
                property string nome: "buscar"
                property bool hover: false
                source: "img/"+ nome +"_normal.png"

                opacity: bola_hover ? 1 : 0
                Behavior on opacity { PropertyAnimation {} }
                
                Image {
                    id: hover
                    source: "img/"+ nome +"_hover.png"
                    opacity: 0
                    Behavior on opacity { PropertyAnimation {} }
                }
                
                MouseArea {
                    anchors.fill: parent
                    hoverEnabled: true
                
                    onEntered: { hover.opacity = 1; bola_hover = true }
                    onExited: { hover.opacity = 0; bola_hover = false }
                }
                

                }
                @

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  DenisKormalev
                  wrote on last edited by
                  #9

                  puelocesar, it makes sense :)

                  1 Reply Last reply
                  0
                  • K Offline
                    K Offline
                    kyleplattner
                    wrote on last edited by
                    #10

                    has anyone ever documented the double mouse area problem to nokia?

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      DenisKormalev
                      wrote on last edited by
                      #11

                      kyleplattner, yes, it was discussed somewhere here at DevNet.

                      1 Reply Last reply
                      0
                      • H Offline
                        H Offline
                        hhartz
                        wrote on last edited by
                        #12

                        But was it logged as a bug report? Please do so or assume it remains lost and undiscovered :)

                        --

                        1 Reply Last reply
                        0
                        • K Offline
                          K Offline
                          kyleplattner
                          wrote on last edited by
                          #13

                          Filed as (QTCREATORBUG-3303).

                          1 Reply Last reply
                          0
                          • A Offline
                            A Offline
                            anselmolsm
                            wrote on last edited by
                            #14

                            For the sake of completeness, link to the bug report. Now it is "QTBUG-15900":http://bugreports.qt.nokia.com/browse/QTBUG-15900

                            Anselmo L. S. Melo (anselmolsm)

                            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