Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. QQmlListProperty in PySide2
Forum Updated to NodeBB v4.3 + New Features

QQmlListProperty in PySide2

Scheduled Pinned Locked Moved Unsolved Qt for Python
pyside2qt for python
3 Posts 3 Posters 544 Views
  • 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.
  • N Offline
    N Offline
    nullptr83
    wrote on 10 Apr 2020, 17:02 last edited by
    #1

    Hi, I'm fairly new to QML, but have been using Qt widgets in C++ and Python since Qt4.x.

    I'm currently interested in using QML with the official PySide2 bindings to create new and extend existing QML types. In order to learn how to do this I've been trying to convert the official examples (https://doc.qt.io/qt-5/qtqml-tutorials-extending-qml-example.html) from C++ to Python.

    I've gotten to tutorial 5, where they start to use QQmlListProperty, but that class doesn't seem to currently exist in the PySide2 bindings (https://wiki.qt.io/Qt_for_Python_Missing_Bindings#QtQml). Is there currently a preferred workaround for this? I've done some experimenting with QAbstractListModel and had a working example using that, but I'm just trying to discover the limitations of the current PySide2 bindings. I'm using PySide2 version 5.14.1.

    1 Reply Last reply
    0
    • W Offline
      W Offline
      wllacer
      wrote on 4 May 2020, 12:02 last edited by
      #2

      I just stumbled on the same stone ;-).
      A cursory search in qt bug database shows that it will be missing with the current version of shiboken ( see https://bugreports.qt.io/browse/PYSIDE-958?jql=text ~ "QQmlListProperty")
      Interestingly there is a reference to a probable bypass via a PySide2.QtQml.ListProperty function, but i've only found it -incompletely. documented for v1 (a sample at https://code.qt.io/cgit/pyside/pyside-setup.git/tree/sources/pyside2/tests/QtQml/registertype.py)
      Some test i made give me following acceptable signature
      tree = ListProperty(PythonType/Class,append=func,at=func,clear=func,count=func)

      I'm just pondering to explore the route, or switching to PyQt5 which does implement the class, but is not LGPL but pure GPL ....

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kkyzivat
        wrote on 4 May 2022, 22:53 last edited by
        #3

        I believe what you are looking for is described in this example:

        https://github.com/qtproject/pyside-pyside-setup/blob/dev/examples/declarative/referenceexamples/properties/doc/properties.rst

        You want to use ListProperty in Python for this. It takes the same parameters as the C++ side does, so referring to the C++ docs for this is helpful.

        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 Extensions
        • Unsolved