Skip to content

Instantly share code, notes, and snippets.

@Siecje Siecje/output
Created Jan 12, 2017

What would you like to do?
Crashes when setting a QQmlListProperty
$ pip install PyQt5==5.7.1
$ python
TypeError: list element must be of type 'str', not 'NoneType'
fish: “python” terminated by signal SIGABRT (Abort)
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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.