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

EditRole of model items seems to lose type info

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • None
    • 5.13.0
    • PySide
    • None
    • Windows 10 build 17763 x64
      Linux
      Python 3.7.3 x64
      PySide2 5.13.0 from PyPI

    Description

      The default editor widget in Qt model views created by QItemEditorFactory depends on which value type has to be edited. For example, integer values should receive a QSpinBox as per QItemEditorFactory documentation.

      With PySide2, it seems that the correct data type is lost somewhere in the Python/QVariant conversion and the C++ side cannot correctly determine which type is stored in the EditRole of an item.

      I have included an example script that creates a list widget with one item that stores an integer in its EditRole. If you run the example with PySide2 and try to edit the item, it will show a QLineEdit (the fallback for strings and everything else) and not a QSpinBox. For comparison purposes, I ran it with PyQt5 and there everything works as intended and the example shows a spin box.

      Same issue exists

      • with custom models
      • in the reverse direction (saved value will be a string since a QLineEdit is used to edit it - can also be seen in the example)

      I haven't actually verified what the C++ code sees in terms of type since I do not have a complete build environment set up, so maybe there is another problem entirely.

      Attachments

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

        Activity

          People

            crmaurei Cristian Maureira-Fredes
            dxpke Philipp Kerling
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes