Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. returning list to QML
Qt 6.12 LTS is out! See what's new in the release blog

returning list to QML

Scheduled Pinned Locked Moved Solved Qt for Python
5 Posts 2 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jim Gir
    wrote on last edited by
    #1

    Hi,
    I'm having trouble returning list from python to QML.
    it's ok with @Property("QVariantList", notify=someNotifier) but I can't make it work with something like @Slot(resultat=list) or Slot(result = "QVariantList").
    Thanks for help :-)

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You should provide a minimal code example that shows your problem.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Jim Gir
        wrote on last edited by
        #3
        class Some(QObject):
          
           fakenotify = Signal()
        
           @Property('QVariantList', notify=fakenotify2)
            def withprop(self):
                with db_session:
                    return self.db.Page.recents()
        
            @Slot(result=list)
            def withslot(self):
                with db_session:
                    return self.db.Page.recents()
        

        in some ListView using as model:
        some.withprop works
        but
        some.whithslot() fails with : qrc:/qml/main.qml:54: TypeError: Cannot call method 'withslot' of null

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Please provide a complete minimal test case including the qml you are using.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • J Offline
            J Offline
            Jim Gir
            wrote on last edited by
            #5

            My bad, it's ok, I had to specify QVariantList in result and not list.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt
            • Unsolved