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

Returning a list of QObject from a Slot only works with instance variables

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4: Low P4: Low
    • None
    • 5.15.2
    • PySide
    • None
    • All

      Hi all,

      from QML I'm trying to get a list of QObject, invoking a Slot. It works only if a instance variable is used to store the list.

       

      For example, the following code works well (it returns a well-formed list of TestModel to QML):

       

      @Slot(result='QVariantList')
      def working_get_all(self):
          self._entries = []
          for i in range(5):
              model = TestModel()
              model.name = 'Name ' + str(i)
              model.description = 'Description ' + str(i)
              self._entries.append(model)
          return self._entries

       

       

      while the following code returns a list of null:

      @Slot(result='QVariantList')
      def not_working_get_all(self):
          entries = []
          for i in range(5):
              model = TestModel()
              model.name = 'Name ' + str(i)
              model.description = 'Description ' + str(i)
              entries.append(model)
          return entries

       

      As attachment there is a complete example for bug reproduction.

       

        1. main.py
          2 kB
        2. main.qml
          1 kB
        3. pyside1596.zip
          2 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            crmaurei Cristian Maureira-Fredes
            ale.tomei Alessandro Tomei
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes