[PyQt] SIGABRT when setting QQmlListProperty

Cody Scott cody at perspexis.com
Thu Jan 12 21:05:16 GMT 2017

I'm using PyQt5==5.7.1.

I'm trying to set a list property from QML. I'm using @pyqtProperty
I'm getting an error that TypeError: list element must be of type 'str',
not 'NoneType' but they are strings in QML.

After that I get a SIGABRT.

Code and output here.

The gist and the attached file are the same.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20170112/7672f499/attachment-0001.html>
-------------- next part --------------
import sys

from PyQt5 import QtCore, QtQml
from PyQt5.QtWidgets import QApplication

class CustomType(QtCore.QObject):
    def __init__(self, parent = None):

        self._names = []

    def names(self):
        return QtQml.QQmlListProperty(str, self, self._names)
    def names(self, names):
        print('Never see this')
        self._names = names

QML = b"""
import QtQuick.Controls 1.4

import CustomType 1.0

ApplicationWindow {
    visible: true
    width: 800
    height: 600

    CustomType {
      id: customType
      names: ["one", "two"]
      //names: [] // doesn't crash

app = QApplication(sys.argv)
QtQml.qmlRegisterType(CustomType, 'CustomType', 1, 0, 'CustomType')
engine = QtQml.QQmlApplicationEngine()

More information about the PyQt mailing list