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. QML Button Pressed/Unpressed Value
Forum Updated to NodeBB v4.3 + New Features

QML Button Pressed/Unpressed Value

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 3 Posters 793 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
    Kallimero
    wrote on last edited by
    #1

    Hello!
    Im new to QML and im trying to get a Button which can deliver the Value:1 if pressed and 0 if unpressed. What properties do i need to go with? I already tried "onPressedChanged" togehter with the checkable/checked property but it doesnt work.

    Thanks in advance :)

    ODБOïO 1 Reply Last reply
    0
    • K Kallimero

      Hello!
      Im new to QML and im trying to get a Button which can deliver the Value:1 if pressed and 0 if unpressed. What properties do i need to go with? I already tried "onPressedChanged" togehter with the checkable/checked property but it doesnt work.

      Thanks in advance :)

      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by
      #2

      @Kallimero hi
      you are looking for pressed

      Button{
          text : pressed ? "1" : "0"
      }
      
      1 Reply Last reply
      0
      • K Offline
        K Offline
        Kallimero
        wrote on last edited by
        #3

        Thank you for the fast reply.
        In my specific case i want to set a value to a variable with a function e.g set_x(value).
        Maybe like this:

                onCheckedChanged: pressed ? set_x(1) :set_x(0)
        

        Unfortunately im still missing something.

        ODБOïO eyllanescE 2 Replies Last reply
        0
        • K Kallimero

          Thank you for the fast reply.
          In my specific case i want to set a value to a variable with a function e.g set_x(value).
          Maybe like this:

                  onCheckedChanged: pressed ? set_x(1) :set_x(0)
          

          Unfortunately im still missing something.

          ODБOïO Offline
          ODБOïO Offline
          ODБOï
          wrote on last edited by
          #4

          @Kallimero said in QML Button Pressed/Unpressed Value:

          onCheckedChanged: pressed ? set_x(1) :set_x(0)

          or simply
          onCheckedChanged : set_x(pressed )

          what are you missing exactly ?

          1 Reply Last reply
          0
          • K Kallimero

            Thank you for the fast reply.
            In my specific case i want to set a value to a variable with a function e.g set_x(value).
            Maybe like this:

                    onCheckedChanged: pressed ? set_x(1) :set_x(0)
            

            Unfortunately im still missing something.

            eyllanescE Offline
            eyllanescE Offline
            eyllanesc
            wrote on last edited by
            #5

            @Kallimero Maybe the problem is in another part of your code, what do you get from using the following?

            onCheckedChanged: {
                console.log(checked)
                if(checked)
                    set_x(1)
                else
                    set_x(0)
            }

            If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

            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