Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-56215

If the SpinBox is not editable, valueFromText should never be called

    XMLWordPrintable

Details

    • 25a3f25ce98c0a88582e97cfcdede970e7cc4a6d

    Description

      1. run this code
        import QtQuick 2.7
        import QtQuick.Controls 2.0
        import QtQuick.Layouts 1.0
        
        ApplicationWindow {
            visible: true
            width: 640
            height: 480
            title: qsTr("Spinbox Test")
            ColumnLayout{
                Button {
                    id:but1
                    text: "Button 1"
                }
                SpinBox {
                    focus: true
                    from: 10
                    to: 1000
                    value: 100
                    editable : false
                    KeyNavigation.backtab: but1
                    KeyNavigation.tab: but2
                    KeyNavigation.left: but1
                    KeyNavigation.right: but2
                    textFromValue : function(value, locale) {
                        console.log("textFromValue called")
                        return Number(value).toLocaleString(locale, 'f', 0);
                    }
                    valueFromText : function(text, locale) {
                        console.log("valueFromText called")
                        return Number.fromLocaleString(locale, text);
                    }
                }
                Button {
                    id:but2
                    text: "Button 2"
                }
            }
        }
        
      2. change the focus with tab
        Current Result : The logs show, that valueFromText was called.
        Expected Result : The logs doesn't show any valueFromText called.
        The problem is if there are custom values like 00:00:00 for time and valueFromText is not implemented changing the tab sets it to 0, because the default implementation can not evaluate it.

      Attachments

        For Gerrit Dashboard: QTBUG-56215
        # Subject Branch Project Status CR V

        Activity

          People

            Unassigned Unassigned
            karimpinter Karim Pinter
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes