Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. qml spinbox editable and validation
Forum Updated to NodeBB v4.3 + New Features

qml spinbox editable and validation

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 405 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.
  • L Offline
    L Offline
    lorenwell
    wrote on last edited by lorenwell
    #1

    HI all,
    I faced a stupid issue and don't find how to solve it.
    I have created a simple qml spinbox editable.

    import QtQuick 2.12
    import QtQuick.Controls 2.12
    import QtQuick.Layouts  1.12
    import QtQuick.Dialogs 1.3
    
    Item {
        property bool isEnableWithoutConnect: true
        property bool disableConnectWidgets: true
    
        ColumnLayout
        {
    
            SpinBox {
                id: spinboxInt
                from : -100
                to : 100
    
                editable: true
            }
        }
    }
    

    When I change the value out of the limit (for example 150) and press enter, the spinbox text is correctly limited to the from property value (the spinbox display 100 and dimmed the + button which is ok). But if I edit the value again to an out of range value (130 for example) and press enter, the text is no more updated to the upper limit. (the spinbox display 130)

    This seems to me not normal. Is it?
    How can I handle this?

    Thanks

    JoeCFDJ 1 Reply Last reply
    0
    • L lorenwell

      HI all,
      I faced a stupid issue and don't find how to solve it.
      I have created a simple qml spinbox editable.

      import QtQuick 2.12
      import QtQuick.Controls 2.12
      import QtQuick.Layouts  1.12
      import QtQuick.Dialogs 1.3
      
      Item {
          property bool isEnableWithoutConnect: true
          property bool disableConnectWidgets: true
      
          ColumnLayout
          {
      
              SpinBox {
                  id: spinboxInt
                  from : -100
                  to : 100
      
                  editable: true
              }
          }
      }
      

      When I change the value out of the limit (for example 150) and press enter, the spinbox text is correctly limited to the from property value (the spinbox display 100 and dimmed the + button which is ok). But if I edit the value again to an out of range value (130 for example) and press enter, the text is no more updated to the upper limit. (the spinbox display 130)

      This seems to me not normal. Is it?
      How can I handle this?

      Thanks

      JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by JoeCFD
      #2

      @lorenwell your qt version may be too low. I just tested your code with Qt 5.15.2 on Ubuntu and it works just fine with qmlscene

      import QtQuick 2.15
      import QtQuick.Controls 2.15
      import QtQuick.Layouts  1.15
      import QtQuick.Dialogs 1.3
      
      Item {
          property bool isEnableWithoutConnect: true
          property bool disableConnectWidgets: true
      
          ColumnLayout
          {
      
              SpinBox {
                  id: spinboxInt
                  from : -100
                  to : 100
      
                  editable: true
              }
          }
      }
      
      L 1 Reply Last reply
      0
      • JoeCFDJ JoeCFD

        @lorenwell your qt version may be too low. I just tested your code with Qt 5.15.2 on Ubuntu and it works just fine with qmlscene

        import QtQuick 2.15
        import QtQuick.Controls 2.15
        import QtQuick.Layouts  1.15
        import QtQuick.Dialogs 1.3
        
        Item {
            property bool isEnableWithoutConnect: true
            property bool disableConnectWidgets: true
        
            ColumnLayout
            {
        
                SpinBox {
                    id: spinboxInt
                    from : -100
                    to : 100
        
                    editable: true
                }
            }
        }
        
        L Offline
        L Offline
        lorenwell
        wrote on last edited by
        #3

        @JoeCFD Yes you are right. I was stay on version 5.12.12.
        I have just try with version 6.6.1 and the control works has expected.
        Very surprise this kind of "bug"/"strange behavior" has stay on version 5.12 which was an LTS.

        Anyway thanks a lot for your answer

        1 Reply Last reply
        0
        • L lorenwell has marked this topic as solved on

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved