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. Spinbox detect pressed
Forum Updated to NodeBB v4.3 + New Features

Spinbox detect pressed

Scheduled Pinned Locked Moved Solved QML and Qt Quick
7 Posts 3 Posters 1.5k 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.
  • M Offline
    M Offline
    mark.lt
    wrote on last edited by
    #1

    Hi,

    is there any way to detect when increase/decrease buttons are pressed?

    There is onValueChanged but I need another method to know when I pressed increase or decrease.

    Thank you.

    raven-worxR 1 Reply Last reply
    0
    • M mark.lt

      Hi,

      is there any way to detect when increase/decrease buttons are pressed?

      There is onValueChanged but I need another method to know when I pressed increase or decrease.

      Thank you.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @mark.lt
      for example:
      https://forum.qt.io/topic/61529/about-qspinbox-how-to-make-it-emit-editingfinished-signal-when-click-the-up-down-arrow-button/7

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1
      • M Offline
        M Offline
        mark.lt
        wrote on last edited by
        #3

        Hmm, is there anyway to do it in QML?

        raven-worxR 1 Reply Last reply
        0
        • M mark.lt

          Hmm, is there anyway to do it in QML?

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @mark.lt
          oh i've overseen that this thread is in the QML forum.

          The SpinBox type does have a corresponding property?!

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          Gojir4G 1 Reply Last reply
          1
          • raven-worxR raven-worx

            @mark.lt
            oh i've overseen that this thread is in the QML forum.

            The SpinBox type does have a corresponding property?!

            Gojir4G Offline
            Gojir4G Offline
            Gojir4
            wrote on last edited by Gojir4
            #5
            This post is deleted!
            1 Reply Last reply
            0
            • Gojir4G Offline
              Gojir4G Offline
              Gojir4
              wrote on last edited by
              #6

              Hi @mark.lt,

              You can work around this pretty easily by creating your own SpinBox component, using down and up properties as suggested by @raven-worx :

              //MySpinBox.qml
               import QtQuick 2.9
              import QtQuick.Controls 2.2
              
              SpinBox{
                  signal decreased(int value)
                  signal increased(int value)
                  down.onPressedChanged: {
                      if(down.pressed){
                          console.log("Decreased")
                          decreased(value)
                      }
                  }
                  up.onPressedChanged: {
                      if(up.pressed){
                          console.log("Increased")
                          increased(value)
                      }
                  }
              }
              

              Usage

              
              MySpinBox{
                  onIncreased: //Value increased
                  onDecreased: //Value decreased
              }
              
              1 Reply Last reply
              0
              • M Offline
                M Offline
                mark.lt
                wrote on last edited by
                #7

                @raven-worx Yeah, I saw that property but my problem was that I needed a signal that tells me when it changes.

                Then I resolved it by creating a property binded to up.pressed or down.pressed then I used the on___Changed then I checked if it is true.

                property bool upPressed: up.pressed
                onUpPressedChanged: {
                 if (up.pressed){
                   //so something
                
                 }
                
                }
                

                @Gojir4 Thanks :D

                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