Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-2417

QDoubleSpinBox.setValue does not accept integers >= 2**31

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3: Somewhat important P3: Somewhat important
    • 6.6.0
    • 6.5.2
    • PySide
    • None
    • Windows
    • f275908ec (dev)

      QDoubleSpinBox.setValue accepts int and double values (which makes sense as long as the int can be converted to a double without loss, which should be true up to 2**52-1).
      However, QDoubleSpinBox.setValue accepts values only up to 2*31-1:
       

      import warnings
      
      from PySide6.QtWidgets import QApplication, QDoubleSpinBox, QSpinBox
      
      warnings.filterwarnings("ignore")
      
      app = QApplication()
      
      int_box = QSpinBox()
      int_box.setValue(2**31 - 1)  # pass
      try:
          int_box.setValue(2**31)  # fail
      except OverflowError:
          print("expected overflow: QSpinBox uses signed int32")
      
      double_box = QDoubleSpinBox()
      double_box.setValue(2**31 - 1)  # pass
      try:
          double_box.setValue(2**31)  # fail
      except OverflowError:
          print("unexpected overflow: Q*Double*SpinBox shold *not* be using signed int32")
      double_box.setValue(2.0**31)  # pass
      

      I am happy there is a workaround in converting the value to float before setting it, but IMHO integers should be accepted without conversion.

        1. pyside2417.py
          0.6 kB
          Friedemann Kleint
        For Gerrit Dashboard: PYSIDE-2417
        # Subject Branch Project Status CR V

            kleint Friedemann Kleint
            bers bers bers
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes