[PyQt] Mysterious type error

Gottfried Müller gottfried.mueller at gmx.de
Sat May 13 16:16:48 BST 2017


I have a mysterious type error and I can't explain it.
In a QListView widget I coded things like this:

class MyWidget(QListView):
    data = pyqtSignal(dict)
    def __init__(...)
       ...
       self.clicked.connect(self.viewClicked)
       ...

    def viewClicked(self, modelIdx):
         viewData = self.model().data(modelIdx, Qt.UserRole)
         print('viewDataType', type(viewData))
         self.data.emit(viewData)
         return

My program crashed with following messages:

viewDataType <class 'dict'>
self.data.emit(viewData)
TypeError:  MyWidget.data[dict].emit(): argument 1 has unexpected type 
'dict'

This kind of error I have in one of my modules only. In other modules 
these code sequences work. I have no idea what is the matter.

Gottfried



More information about the PyQt mailing list