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. [solved] Invisible items do not receive mouse events
QtWS25 Last Chance

[solved] Invisible items do not receive mouse events

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 3 Posters 1.3k 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.
  • D Offline
    D Offline
    DimanNe
    wrote on last edited by
    #1

    According to "this":http://qt-project.org/doc/qt-4.8/qml-item.html:

    bq. In contrast, setting the visible property to false stops both mouse and keyboard events, and also removes focus from the item

    hidden item does not receive mouse events...

    Lets consider that I want to achieve horizontal item fading (left to right), so I use "OpacityMask":http://qt-project.org/doc/qt-5.0/qtgraphicaleffects/qml-qtgraphicaleffects1-opacitymask.html in which maskSource is LinearGradient (with animated GradientStop position).

    Here is example of how to use "OpacityMask":http://qt-project.org/doc/qt-5.0/qtgraphicaleffects/qml-qtgraphicaleffects1-opacitymask.html:
    @
    Image {
    id: bug
    //...
    visible: false
    }

    Image {
        id: mask
        //...
        visible: false
    }
    
    OpacityMask {
        anchors.fill: bug
        source: bug
        maskSource: mask
    }
    

    @

    as you can see both items hidden => my item with controls does not receive mouse events though it is shown on the screen but visible property is false!

    So, how can I achieve fading effect AND receive mouse events?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Set visible to true and opacity to some minimal value like 0.01 or so.

      (Z(:^

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sreich
        wrote on last edited by
        #3

        @sierdzio, shouldn't 0.0 be fine? or is that implicitlyi setting visible to false?

        Software Developer for KDE

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          [quote author="sreich" date="1381152369"]@sierdzio, shouldn't 0.0 be fine? or is that implicitlyi setting visible to false?[/quote]

          I think it will set visible to false, too. I guess the best answer is to try it out for yourself. IIRC, there is also a behaviour change here between QtQuick 1 and 2.

          (Z(:^

          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