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. Controls 2 - SpinBox problems

Controls 2 - SpinBox problems

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 3 Posters 668 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.
  • P Offline
    P Offline
    prollings
    wrote on last edited by
    #1

    I'm trying to build an application that involves quite a few spinboxes, I'm using controls v2.
    Things I'd like to see, but can't seem to find:

    1. "onIncrement" and "onDecrement" signals. Am I missing something here?
    2. the "decimals" property of v1 spinboxes. Why has that been removed?

    I've ended up solving both, but the solutions are far from elegant or obvious, and it seems like these are two things that should be in the API in the first place.
    Is there something I'm missing here?

    Thanks

    J.HilkJ 1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      how about using the onValueChanged().. signal. This should help you.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • P prollings

        I'm trying to build an application that involves quite a few spinboxes, I'm using controls v2.
        Things I'd like to see, but can't seem to find:

        1. "onIncrement" and "onDecrement" signals. Am I missing something here?
        2. the "decimals" property of v1 spinboxes. Why has that been removed?

        I've ended up solving both, but the solutions are far from elegant or obvious, and it seems like these are two things that should be in the API in the first place.
        Is there something I'm missing here?

        Thanks

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        @prollings

        mmh, seems easy enough to implement yourself:

        SpinBox{
             property int lastValue: 0
             signal increment()
             signal decrement()
        
            onValueChanged: {
                 if(value - lastValue ===  1)//With this increment/decrement is only invoked with the value changes by exactly 1
                     increment()
                 if(value - lastValue === -1)
                     decrement()
                 lastValue = value;
            }
        }
        

        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.

        P 1 Reply Last reply
        1
        • J.HilkJ J.Hilk

          @prollings

          mmh, seems easy enough to implement yourself:

          SpinBox{
               property int lastValue: 0
               signal increment()
               signal decrement()
          
              onValueChanged: {
                   if(value - lastValue ===  1)//With this increment/decrement is only invoked with the value changes by exactly 1
                       increment()
                   if(value - lastValue === -1)
                       decrement()
                   lastValue = value;
              }
          }
          
          P Offline
          P Offline
          prollings
          wrote on last edited by
          #4

          @J.Hilk
          Thank you, that's a fairly elegant way of doing that. I'm perhaps too new and didn't know it could be so simple. Coupled with the the "official" solution for turning it into a float spin box, controls2 spinbox is actually okay!...

          Thanks

          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