[PySide] signal connection only works with lambda
Cristian.Maureira-Fredes at qt.io
Thu Sep 1 09:23:20 CEST 2022
Could you maybe share more code using
services like pastebin.com or any other?
Images are a bit hard to understand, because
often they lack of context.
If you think you encounter a bug,
maybe you can open a bug report,
but for that, please share the code of a minimal reproducible
On 9/1/22 06:00, Frank Rueter wrote:
> Hi Christian,
> sorry for the delay.
> Yes, the signal is declared in the class but not inside any function.
> I had not used the @Slot decorator but tried it just now to no avail.
> On Tue, Aug 30, 2022 at 7:21 PM Cristián Maureira-Fredes
> <Cristian.Maureira-Fredes at qt.io <mailto:Cristian.Maureira-Fredes at qt.io>>
> On 8/30/22 00:08, Frank Rueter wrote:
> > Hi all,
> Hey Frank,
> > probably a pre-coffee hiccup:
> > I have this weird issue where my signal connection only works when
> > utilising lambda, even though the data type sent by the signal is
> > exactly what the receiving slot needs.
> > This is my code:
> > In a worker class (QRunnable) I emit this signal
> > * tasks_data_available = QtCore.Signal(list)
> > *
> Just a sanity check:
> That's declared inside a class, but not inside any method, right?
> > In my main widget I connect it like this:
> > * worker.tasks_data_available.connect(self.__prep_task_data)
> > *
> > the slot looks like this:
> > * def __prep_task_data(self, task_list):
> > *
> > * print(task_list)*
> Is this method decorated with a `@Slot(list)` ?
> def __prep_task_data(elf, task_list):
> > I have done this countless times, but for some reason in this
> case the
> > code never calls the slot when the QRunnable emits task_list.
> > When I do this it works though:
> > * worker.tasks_data_available.connect(lambda t:
> > self.__prep_task_data(t))
> > *
> This might be due to the lazy registration of the lambda as a Slot,
> without properly going through the Slot-registration process.
> > What am I missing? I should not have to use lambda in this case.
> It might be the missing @Slot,
> but let me know if that's not the case.
> > Cheers,
> > frank
> Dr. Cristián Maureira-Fredes
> Senior R&D Manager
> The Qt Company GmbH
> Erich-Thilo-Str. 10
> D-12489 Berlin
> Geschäftsführer: Mika Pälsi,
> Juha Varelius, Jouni Lintunen
> Sitz der Gesellschaft: Berlin,
> Registergericht: Amtsgericht
> Charlottenburg, HRB 144331 B
> PySide mailing list
> PySide at qt-project.org <mailto:PySide at qt-project.org>
Dr. Cristian Maureira-Fredes
Senior R&D Manager
The Qt Company GmbH
Geschäftsführer: Mika Pälsi,
Juha Varelius, Mika Harjuaho
Sitz der Gesellschaft: Berlin,
Charlottenburg, HRB 144331 B
More information about the PySide