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

DoubleSpinBox.valueChanged fires without the value having changed when setting maximum to NaN

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P4: Low
    • None
    • 6.4.1
    • Quick: Widget
    • None
    • Windows

    Description

      Setting the maximum of a QDoubleSpinBox to NaN sets its value to NaN. This is not documented, but it is not documented that it does not do that, so I can kind of accept it.

      However, when doing so repeatedly, QDoubleSpinBox.valueChanged fires repeatedly although the value has not changed.

      I created a Python-based example at https://bugreports.qt.io/browse/PYSIDE-2126. Unfortunately, I do not have a Qt-C++ dev environment installed, so I have not way of translating it. but I guess it is easy enough to read in Python code, the gist being:

      QApplication()
      box = QDoubleSpinBox()
      box.valueChanged.connect(lambda: print("This should print only once."))
      box.setMaximum(math.nan) # this calls value_changed, as expected (I guess)
      box.setMaximum(math.nan) # this calls value_changed, certainly unexpected!

      I would expect the second call to setMaximum to not fire anything, as the maximum hasn't changed and the value hasn't changed.

      Attachments

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

        Activity

          People

            tvete Paul Olav Tvete
            bers bers bers
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes