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

If you give a QComboBox a python instance that implements the sequence protocall, you get a list back

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • 5.11.2
    • 1.2.2
    • PySide
    • None
    • Linux/X11
    • d55816ebe8e9b50c325d98dd70fbbaa35bf023c0

    Description

      This code fails in PySide1 as well as PySide2.

      from __future__ import print_function
      
      from PySide2 import QtWidgets
      
      class MyItem(object):
          def __init__(self, name):
              self.name = name
      
          def __repr__(self):
              return '<MyItem({})>'.format(self.name)
      
      
      
      class MyContainer(object):
          """docstring for MyContainer"""
      
          def __init__(self, items):
              self.items = items
      
          def __len__(self):
              return len(self.items)
      
          def __getitem__(self, index):
              return self.items[index]
      
          def __repr__(self):
              return '<MyContainer({})>'.format(', '.join([repr(item)
                                                          for item in self.items]))
      
      
      if __name__ == "__main__":
          app = QtWidgets.QApplication([])
          container = MyContainer([MyItem('Jim'),
                                   MyItem('apple'),
                       MyItem('dinosaur')])
          print(container, type(container))
          combo = QtWidgets.QComboBox()
          combo.addItem('container', container)
          container_from_qt = combo.currentData()
          print(container_from_qt, type(container_from_qt))
          assert type(container) == type(container_from_qt)
      

      I'm unsure if PYSIDE-641 or PYSIDE-65 are related, but its all that came up when I searched around.

      Attachments

        Issue Links

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

          Activity

            People

              crmaurei Cristian Maureira-Fredes
              russell Russell Pearsall
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes