0

Hi,

I've created new signal , where i specify list and object datatype.

dataChanged = QtCore.Signal(list, object)

But list and object datatype don't convey properly that what will be in list and in the object.
So it would be good if we could declare something like this,

dataChanged = QtCore.Signal(lst_employees, obj_sender)

so that, if anyone sees the code, would understand easily. But i don't know it's possible in Python or not.

But i have done something like this, i don't know this is correct or not

lst_employees = list
obj_sender = object

dataChanged = QtCore.Signal(lst_employees, obj_sender)

Is this right and pythanic way to use ? Please guide me.

Thanks
Ravi

2
Contributors
1
Reply
50
Views
3 Years
Discussion Span
Last Post by Gribouillis
0

I don't know a lot of Qt, but this tutorial says that you can pass any python types to Signal(). From the interpreter's point of vue, there is no difference between

lst_employees = list
obj_sender = object
dataChanged = QtCore.Signal(lst_employees, obj_sender)

and

dataChanged = QtCore.Signal(list, object)

If you want to specialize the code from the interpreter's point of vue, you can try to define a subclass for example

class LstEmployees(list):
    pass
obj_sender = object
dataChanged = QtCore.Signal(LstEmployees, obj_sender)

Edited by Gribouillis

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.