PySide Bugzilla Closed for New Bugs

PySide is now a Qt Add-on and uses the Qt Project's JIRA Bug Tracker instead of this Bugzilla instance. This Bugzilla is left for reference purposes.

Bug 950 - implement Q_INVOKABLE
: implement Q_INVOKABLE
Status: CLOSED FIXED
Product: PySide
Classification: Unclassified
Component: QtCore
: HEAD
: All All
: P3 normal
Assigned To: Hugo Parente Lima
:
:
:
  Show dependency treegraph
 
Reported: 2011-07-30 16:25 EEST by Farsmo
Modified: 2011-08-23 00:35 EEST (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Farsmo 2011-07-30 16:25:02 EEST
There is currently no way to simulate Q_INVOKABLE in PySide. Invokable methods
are similar to slots but they are able to return a value. For example this is
necessary when you use QWebFrame.addToJavaScriptWindowObject: otherwise the
functions you define cannot return a value to Javascript.

There was some discussion a while back on the mailing list, which didn't end
with a decision. Two proposals were made:
- define an @Invokable decorator similar to @Slot;
- or extend Slot so that if the function returns a value this value will be
returned on invokation.

Since most slots are invoked asynchronously and don't return a value, it
probably makes sense to have a different decorator to distinguish those few
methods that do return a value. If I remember past discussions correctly, one
of the goals of the PySide team was to avoid deviating from Qt if it wasn't
necessary: from that point of view keeping the Invokable/Slot distinction seems
reasonable.

What do you think?
Comment 1 Hugo Parente Lima 2011-08-01 18:58:34 EEST
I agree with you.

Past discussion about it:
http://lists.pyside.org/pipermail/pyside/2010-November/001412.html
Comment 2 renato filho 2011-08-01 21:36:48 EEST
did you try use slot with return values? What is the problem with that?

you can check the example on:
https://github.com/PySide/PySide/blob/master/tests/signals/decorators_test.py
Comment 3 Farsmo 2011-08-07 01:03:44 EEST
Thanks, I didn't know about the result argument! It definitely solves the use
case I had in mind.

Perhaps the documentation could mention that this is the reason why Q_INVOKABLE
is not needed?
Comment 4 Hugo Parente Lima 2011-08-16 20:54:32 EEST
I added some notes on Slot documentation about Q_INVOKABLE methods.

Fixed on commit:

pyside/0293a3ce36d22a32159ba286ab48b0087acc34d6
Comment 5 renato filho 2011-08-23 00:35:31 EEST
Released on PySide 1.0.6