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. Problem with states when pressed
Forum Updated to NodeBB v4.3 + New Features

Problem with states when pressed

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 2 Posters 1.1k 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.
  • K Offline
    K Offline
    kolegs
    wrote on last edited by
    #1

    Hi,

    I have created an app which have some custom buttons. I have created those buttons by using Image and MouseArea. Unfortunately I got problem with states I have a black rectangle on top of Image and I set opacity to 75% when you press mousearea. What is more those buttons are shown on flickable. The problem is when you click on the button and then start to flick the area, then sometimes the black rectangle stays visible even if I stop clicking on it. There is a port of code with Image:
    @Image {
    asynchronous: true
    objectName: "ima"
    id: ima
    x: 0
    y: 0
    height: parent.height
    width: parent.width
    fillMode: Image.PreserveAspectFit
    source: "light_off_button.png"
    Rectangle{
    id: ima_clicked
    width: parent.width
    height: parent.height
    x: parent.width/18
    y: x
    color: "black"
    visible: false
    }

        states: State {
            when: icon.pressed
            PropertyChanges { target: mask; opacity: 0.75 }
        }
    
        MouseArea{
            id: icon
            anchors.rightMargin: 0
            x: 0
            y: 0
            height: parent.height
            width: parent.width
            onClicked: {
                action()
            }
            onCanceled: {
                mask.opacity=0
            }
        }
    
    }
    OpacityMask{
        id: mask
        width: ima.width
        height: ima.height
        opacity: 0
        source: ima_clicked
        maskSource: ima
    }@
    
    1 Reply Last reply
    0
    • R Offline
      R Offline
      Roumed
      wrote on last edited by
      #2

      If i'm not mistaken, there is no code to make ima_clicked.visible == true. With this code it should be always invisible.

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kolegs
        wrote on last edited by
        #3

        yeah I know, but it will make mask visible, I use it because my image has irregular shape

        1 Reply Last reply
        0
        • R Offline
          R Offline
          Roumed
          wrote on last edited by
          #4

          Which state is set when you release mouse?

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kolegs
            wrote on last edited by
            #5

            When you release mouse this state
            @states: State {
            when: icon.pressed
            PropertyChanges { target: mask; opacity: 0.75 }
            }@
            stops working because of when is not set to true, it works fine withour flickable. But with flickable area from time to time when i click a button it gets dark(state works) and move my finger a little bit signal about releasing it is not sent. I think its because flickable get the signals now.

            in 95% it works perfectly but there is this 5% that is annoying and I am not sure if my app freezed or its just this bug

            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