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. Continuously check something while mouse area is pressed

Continuously check something while mouse area is pressed

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 3.7k 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.
  • N Offline
    N Offline
    nhojyer07
    wrote on last edited by
    #1

    Hi! My first topic here! Anyway, here's my problem:

    @Button {
    id: rightkey
    x: 104
    y: 49
    normalImage: "Images/right1.png"
    pressedImage: "Images/right2.png"

        onPressed: {
            if (!player.rightCollide)
                player.status = "run_r";
        }
        onReleased: player.status = "idle_r";
    }@
    

    The Button element is just an Image element with a MouseArea inside it. The problem lies on onPressed. You can see above that it checks if the condition is false but what I need is checking that condition continuously while the button is pressed. Do I need to do something else to achieve that?

    Thank you in advance. Hope you can help me with this.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mlong
      wrote on last edited by
      #2

      You could use the onPressed: action to start a repeating Timer which does your check. Then use the onReleased: action to stop the timer.

      Software Engineer
      My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

      1 Reply Last reply
      0
      • N Offline
        N Offline
        nhojyer07
        wrote on last edited by
        #3

        Haven't thought of that. Thanks mlong! Be trying it later.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mlong
          wrote on last edited by
          #4

          No problem! I've done something similar before and it worked great. Good luck!

          Software Engineer
          My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

          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