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 847 - Slots on QDeclarativeView subclass can't be called from QML/JavaScript
: Slots on QDeclarativeView subclass can't be called from QML/JavaScript
Status: CLOSED FIXED
Product: PySide
Classification: Unclassified
Component: Shiboken
: HEAD
: PC Linux
: P3 normal
Assigned To: Marcelo Lira
:
:
:
  Show dependency treegraph
 
Reported: 2011-05-04 17:09 EEST by Thomas Perl
Modified: 2011-07-02 22:25 EEST (History)
9 users (show)

See Also:


Attachments
Test case: 2x Python source (1 bug, 1 workaround) + 1x QML file (789 bytes, application/x-gzip)
2011-05-04 17:14 EEST, Thomas Perl
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Perl 2011-05-04 17:09:31 EEST
When I subclass QDeclarativeView and add slots there, and expose an instance of
this subclass to QML (e.g. using setProperty on the root object), the slot
can't be called from QML/JavaScript.

However, if I subclass QObject directly and add the slots there, and then
create an instance of this QObject subclass and set it as property in the QML
root object, the slots can be called normally without problems.

I'll attach a test case demonstrating the problem.
Comment 1 Thomas Perl 2011-05-04 17:14:05 EEST
Created attachment 322 [details]
Test case: 2x Python source (1 bug, 1 workaround) + 1x QML file

This is the test case. Usage:

1.) python bug847.py
2.) Click somewhere in the window

Expected outcome: blubb() gets called in Python
Actual outcome: file:///home/thp/pyside-bug/bug847.qml:22: TypeError: Result of
expression 'pythonObject.blubb' [undefined] is not a function.

Usage for the workaround (to show that it works when subclassing QObject):

1.) python bug847_workaround.py
2.) Click somewhere in the window

Expected + actual outcome: blubb() gets called in Python
Comment 2 renato filho 2011-05-09 21:46:28 EEST
fixed on shiboken commit:

commit 15b9f58747c6951a345648765190cdd4e7554c9d
Author: Renato Filho <renato.filho@openbossa.org>
Date:   Fri May 6 19:03:59 2011 -0300
Comment 3 renato filho 2011-05-26 17:04:05 EEST
PySide release 1.0.3
Comment 4 Anderson Lizardo 2011-05-28 03:25:19 EEST
For some reason this test is failing for me:

339: Test command: /usr/bin/python2.6
/home/lizardo/trees/pyside/pyside.git/tests/QtDeclarative/bug_847.py
339: Test timeout computed to be: 60
339: F
339: ======================================================================
339: FAIL: testPythonSlot (__main__.TestQML)
339: ----------------------------------------------------------------------
339: Traceback (most recent call last):
339:   File
"/home/lizardo/trees/pyside/pyside.git/tests/QtDeclarative/bug_847.py", line
39, in testPythonSlot
339:     self.assertTrue(self._sucess)
339: AssertionError
339: 
339: ----------------------------------------------------------------------
339: Ran 1 test in 0.196s
339: 
339: FAILED (failures=1)

Environment:

Qt 4.7.3 (from Qt SDK 1.1.1)
PySide 1.0.3
Python 2.6.5
Comment 5 Lauro Moura 2011-07-02 22:25:52 EEST
Yep, still failing here with the same error as Lizardo. Should it be reopened?

Ubuntu Natty on a 32-bit celeron.
PySide from GIT
Qt 4.7.2 from Ubuntu Natty
Python 2.7.1+ from Ubuntu Natty.

AFAIR it was also failing in with Qt from GIT, PySide from GIT and Python 2.6
from Ubuntu Maverick on a 64-bit MacBook Pro.