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

Setting data to a QStandardItem doesn't store a reference to the object if it's datatype is a subclass of list

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 5.15.0
    • PySide
    • None

    Description

      I am trying to set the data of a `QStandardItem`. The datatype of the data prior to the assignment is a subclass of `list`. If I try to access the object afterwards the datatype has changed to `list`.

      According to the documentation a reference should be stored and that's also what I would expect in PySide2.

      However, it looks like `setData` is trying to copy the object instead of storing a reference.

      The behaviour only affects subclasses of list. Subclasses of dict/set/tuple work fine.
       

      from PySide2 import QtGui
      
      class Q(list):
          pass
      
      item = QtGui.QStandardItem()
      obj = Q()
      
      type(obj)             # <class '_main_.Q'>
      item.setData(obj)
      type(item.data())     # <class 'list'>
      

      Attachments

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

        Activity

          People

            crmaurei Cristian Maureira-Fredes
            kh4l3th Benjamin Werther
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes