[PySide] What is being used instead of @pyqtSignature?

664 views
Skip to first unread message

Mark Summerfield

unread,
Mar 10, 2011, 11:11:30 AM3/10/11
to pys...@lists.pyside.org
Hi,

The purpose of the @pyqtSignature decorator is to help the uic-generated
file's setupUi() method's connectSlotsByName() call be able to correctly
connect methods that are reimplementations of slots that have two or
more overloads.

For example the QPushButton.clicked() signal has one overload that has
no argument and another that has a bool (to indicate its toggle state).

So whereas in PyQt I'd write:

@pyqtSignature("")
def on_button_clicked(self):
# handle the non-toggle case

@pyqtSignature("bool")
def on_button_clicked(self):
# handle the toggle case separately

how would I do it in PySide?

(I know my example doesn't make sense; it is just to illustrate the
question.)

Thanks!

--
Mark Summerfield, Qtrac Ltd, www.qtrac.eu
C++, Python, Qt, PyQt - training and consultancy
"Programming in Python 3" - ISBN 0321680561
http://www.qtrac.eu/py3book.html
_______________________________________________
PySide mailing list
PyS...@lists.pyside.org
http://lists.pyside.org/listinfo/pyside

Hugo Parente Lima

unread,
Mar 10, 2011, 12:53:09 PM3/10/11
to pys...@lists.pyside.org
On Thursday 10 March 2011 13:11:30 Mark Summerfield wrote:
> Hi,
>
> The purpose of the @pyqtSignature decorator is to help the uic-generated
> file's setupUi() method's connectSlotsByName() call be able to correctly
> connect methods that are reimplementations of slots that have two or
> more overloads.

On PySide connectSlotsByName() only works with slots registered into
metaobject, so you have to decorate your on_x_y methods with @Slot decorator,
in the @Slot decorator you put the method signature, this also should work
with PyQt.



> For example the QPushButton.clicked() signal has one overload that has
> no argument and another that has a bool (to indicate its toggle state).
>
> So whereas in PyQt I'd write:
>
> @pyqtSignature("")
> def on_button_clicked(self):
> # handle the non-toggle case
>
> @pyqtSignature("bool")
> def on_button_clicked(self):
> # handle the toggle case separately
>
> how would I do it in PySide?
>
> (I know my example doesn't make sense; it is just to illustrate the
> question.)
>
> Thanks!

--
Hugo Parente Lima
INdT - Instituto Nokia de Tecnologia

signature.asc
Reply all
Reply to author
Forward
0 new messages