[PyQt] Signal causes seg fault

Cody Scott cody at perspexis.com
Thu Jan 12 17:43:40 GMT 2017

I'm getting a seg fault when a child class calls a method of a parent class
which emits a signal (also of the parent class).

If you run this example file and click the button it will cause a segfault.
If nothing is bound to "customType.count" then it will not segfault.

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/dd5fcd5e/attachment.html>
-------------- next part --------------
import sys

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

class BaseOutput(QtCore.QObject):
    countChanged = QtCore.pyqtSignal()

    def __init__(self, parent = None):

    @QtCore.pyqtProperty(int, notify = countChanged)
    def count(self):
        return 1
    def setCount(self):
        self.countChanged.emit() # Seg fault after this line

class CustomType(BaseOutput):
    def __init__(self, parent = None):

QML = b"""
import QtQuick 2.7
import QtQuick.Controls 1.4

import CustomType 1.0

ApplicationWindow {
    visible: true
    width: 800
    height: 600

    CustomType {
      id: customType

    Column {
      Text { text: customType.count }
      Button {
        text: "Change count"
        onClicked: {


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


More information about the PyQt mailing list