Phil Thompson phil at riverbankcomputing.com
Tue Feb 2 15:43:36 GMT 2021

On 02/02/2021 15:11, Rodrigo de Salvo Braz wrote:
> Hi,
> I'm reading Martin Fitzpatrick's book on PyQt and came across this 
> example
> which includes a signal indexed by the function str:
> widget = QSpinBox()
> widget.valueChanged[str].connect(self.value_changed_str)
> I have a few questions:
> Q1. Why not have a signal named textChanged instead? That would match 
> Qt's
> reference <https://doc.qt.io/qt-5/qspinbox.html>. And I guess it would 
> look
> more usual.

You can use that signal if you want to, but is was only added in Qt 

> Q2. Can other functions or types be used as index too, or just str?

The index corresponds to the signature of the particular signal overload 
you want to connect.

> Q2. How could I have figured how to use this from PyQt's reference or 
> Qt's
> reference by myself (if I had not seen the example in the book)? PyQt's
> reference
> <https://www.riverbankcomputing.com/static/Docs/PyQt5/api/qtwidgets/qspinbox.html?highlight=qspinbox>
> indicates two signals, valueChanged(int) and valueChanged(str). Is 
> there
> some kind of convention that would allow me to understand how to use
> valueChanged[str] from these documentation descriptions?


It would seem that Qt is moving away from having overloaded signals - a 
good thing.


More information about the PyQt mailing list