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. "Clicking" MouseArea when State changes

"Clicking" MouseArea when State changes

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 375 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
    krokstr
    wrote on last edited by
    #1

    Hello, I'm looking for solution of the problem bellow:

     mArea5{
            onClicked: {
                if(shuffle_background.color == "#ffffff")
                {
    
                }else{
                    rect.color = "#005757"
                    rect1.color = "#005757"
                    rect2.color = "#005757"
                    rect3.color = "#005757"
                    rect4.color = "#005757"
                    rect5.color = "white"
                    shuffle_background.color = "#005757"
                    //font_color_change
                    text1.color = "white"
                    text2.color = "white"
                    text3.color = "white"
                    text4.color = "white"
                    text5.color = "white"
    
                    row_value = 5
                }
            }
        }
        states: [
            State {
                name: "f5"
                PropertyChanges {
                    target: mArea5 ; clicked:(mArea5)
    
                }
            },
            State {
                name: "f4"
                PropertyChanges {
                    target: mArea4 ; pressed:(true)
                }
            }
    ]
    

    I want to select the state "f5" from other qml file, resulting in emulated click of "mArea5", how should I do this?
    Thanks in advance!

    J.HilkJ 1 Reply Last reply
    0
    • K krokstr

      Hello, I'm looking for solution of the problem bellow:

       mArea5{
              onClicked: {
                  if(shuffle_background.color == "#ffffff")
                  {
      
                  }else{
                      rect.color = "#005757"
                      rect1.color = "#005757"
                      rect2.color = "#005757"
                      rect3.color = "#005757"
                      rect4.color = "#005757"
                      rect5.color = "white"
                      shuffle_background.color = "#005757"
                      //font_color_change
                      text1.color = "white"
                      text2.color = "white"
                      text3.color = "white"
                      text4.color = "white"
                      text5.color = "white"
      
                      row_value = 5
                  }
              }
          }
          states: [
              State {
                  name: "f5"
                  PropertyChanges {
                      target: mArea5 ; clicked:(mArea5)
      
                  }
              },
              State {
                  name: "f4"
                  PropertyChanges {
                      target: mArea4 ; pressed:(true)
                  }
              }
      ]
      

      I want to select the state "f5" from other qml file, resulting in emulated click of "mArea5", how should I do this?
      Thanks in advance!

      J.HilkJ Online
      J.HilkJ Online
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      hi @krokstr

      I would move the stuff thats part of onClicked to its own function.

      Than you can call the function from the onClick event or from whereever else in the code.


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

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

        Thank you @J.Hilk !

        I'm posting the solution:

        mArea5{
                onClicked: {
                    on_f5_clicked()
                }
        }
         states: [
                State {
                    name: "f5"
                    StateChangeScript{
                        name: "f5Script"
                        script: on_f5_clicked()
                    }
        ]
        function on_f5_clicked()
            {
                if(shuffle_background.color == "#ffffff")
                {
        
                }else{
        
                    rect.color = "white"
                    rect1.color = "#005757"
                    rect2.color = "#005757"
                    rect3.color = "#005757"
                    rect4.color = "#005757"
                    rect5.color = "#005757"
                    shuffle_background.color = "#005757"
                    //font_color_change
                    text1.color = "black"
                    text2.color = "white"
                    text3.color = "white"
                    text4.color = "white"
                    text5.color = "white"
        
                    row_value = 4
                }
        
            }
        
        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