I have a PySide widget, with some connections. There are times when they are simply replaced by new widget instances based on input. How can I retain (getting the connections is the difficult part for me) all the connections of the previous instance, which were defined earlier(at the time of first creation)?
Share
Reading the documentation for
QObjectit is clear that its API does not provide what you want.The best you can do is retrieve the number of objects connected to a single signal of your
QObject. Nothing more.If you want to retrieve the objects connected you can only add them to a sequence(list/dict/set) when you first instantiate the widget and when changing the widget iterate over them and reconnect the widgets to the new object.
(You’ll have to save both the connected widgets and the signals used as connection)
An other option can be to create a custom event/signal and when you replace the widget you emit this signal providing the new instance so that all the widgets can reconnect themselves.