[PySide] What if a slot is not decorated with @Slot()?

Christian Tismer-Sperling tismer at stackless.com
Fri Nov 18 12:02:29 CET 2022


Hi Zhao,

there is a configuration problem between Qt and PySide signals and
slots. The Qt signals and slots are assigned once at compile time.

On PySide, initialization is different since some things happen
earlier or later. There *can* be situations constructed which go wrong,
although doing that is difficult. You will not want to run into these
problems by accident.

Please believe me as one of the implementers:
There is only one safe way to create reliable signals and slots.
Use the decorator!

Cheers - Chris


On 16.11.22 15:18, Zhao Lee wrote:
> I initially expect that the aim of the decorator @Slot() is to make 
> things easier like this
> https://uwsgi-docs.readthedocs.io/en/latest/PythonDecorators.html#notes 
> <https://uwsgi-docs.readthedocs.io/en/latest/PythonDecorators.html#notes>
> and without the decorator , you'd expect write a little more code like
> https://uwsgi-docs.readthedocs.io/en/latest/Signals.html?#timers 
> <https://uwsgi-docs.readthedocs.io/en/latest/Signals.html?#timers>
> But decorators in PySide become a little different. I know the decorator 
> can make the signal and slot connection a bit easier in PyQt in this way
> */    @Slot(QModelIndex)/*
> */    def on_downloadedView_doubleClicked(self, index) :/*
> */           pass/*
> But I still doubt the necessity of the decorator here if we write the 
> slot method name in this way. I wonder if it is possible to simplify the 
> mechanism in PySide like that in the above example of uwsgi without 
> requiring it is mandatory(In fact as I posted in last email, it seems 
> still ok without the decorator, although the doc states it is mandatory 
> to exist).


-- 
Christian Tismer-Sperling    :^)   tismer at stackless.com
Software Consulting          :     http://www.stackless.com/
Strandstraße 37              :     https://github.com/PySide
24217 Schönberg              :     GPG key -> 0xFB7BEE0E
phone +49 173 24 18 776  fax +49 (30) 700143-0023



More information about the PySide mailing list