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

SpinBox emits onValueChanged before it is completed

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.2.0
    • 5.2.0
    • Quick: Controls 1
    • None
    • Windows7 32-bit, most likely any platform.
    • ac39d220f2989286d871a16f064f4de69098f167

    Description

      If SpinBox has a value bound to a constant, it will emit onValueChanged with that value before the SpinBox is completed.
      This can cause problems, since you cannot rely on that other items it depends on are constructed in the onValueChanged signal.

      import QtQuick 2.1
      import QtQuick.Controls 1.1
      
      Rectangle {
          width: 300
          height: 200
          
          Item {
              SpinBox {
                  value: 42
                  Component.onCompleted: console.log("SpinBox onCompleted, rect:" + rect);
                  onValueChanged: {
                      console.log("SpinBox onValueChanged: " + value + ", rect:" + rect);
                  }
              }
          }
          Rectangle {
              id: rect
          }
      }
      

      Shows

      SpinBox onValueChanged: 42, rect:null(13):SpinBox onValueChanged: 42, rect:null
      SpinBox onCompleted, rect:QQuickRectangle(0x3f4e420)
      

      Removing value: 42 will cause it to not emit onValueChanged

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            mitch_curtis Mitch Curtis
            smd Jan Arve
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes