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

Default QItemEditorFactory doesn't create QSpinBox when creating editor for a integer, creates QLineEdit instead

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • None
    • 5.14.1
    • PySide
    • None
    • Python 3.8.2
    • Windows
    • 308aba2154699596e3fd0973501213423462a80b (pyside/pyside-setup/5.14)

    Description

      In this code, which inserts data into a QStandardItemModel (called resourcesModel) with QTableView:

      item = QStandardItem()
      item.setData(123123, Qt.EditRole)
      resourcesModel.setItem(1, 1, item)
      

      double-clicking on a cell presents a default QLineEdit (which you can put letters into), instead of QSpinBox, which would be expected since data is an integer.

      Possible explanation (by user eyllanesc on StackOverflow):

      What happens is that PySide2 converts the integer from python to LongLong (QVariant::LongLong=4) in C++ which is not handled by the default QItemEditorFactory by default making a QLineEdit used (in PyQt is converted to QMetaType::Int=2).

      Attachments

        1. pyside1250.py
          0.7 kB
        2. pyside1250_cpp.zip
          3 kB

        Issue Links

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

          Activity

            People

              kleint Friedemann Kleint
              deronek Mateusz Dionizy
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes