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 980 - Return PySide.MetaFunction for function objects
: Return PySide.MetaFunction for function objects
Status: CLOSED WONTFIX
Product: PySide
Classification: Unclassified
Component: QtDeclarative
: 1.0.5
: All All
: P3 normal
Assigned To: Hugo Parente Lima
:
:
:
  Show dependency treegraph
 
Reported: 2011-08-19 02:54 EEST by Daniel Ashbrook
Modified: 2011-09-21 21:19 EEST (History)
8 users (show)

See Also:


Attachments
C++ version of the example (634 bytes, text/plain)
2011-08-31 17:23 EEST, Hugo Parente Lima
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Ashbrook 2011-08-19 02:54:06 EEST
I'm probably abusing QML/Pyside a bit, but I have my reasons...

Given the following QML (func.qml):

  import Qt 4.7
  Rectangle
  {
    function hello() { }
    property variant stuff: {'hello': hello}
  }

and python:

  from PySide.QtCore import QUrl
  from PySide.QtGui import QApplication
  from PySide.QtDeclarative import QDeclarativeView

  app = QApplication([])
  v = QDeclarativeView()
  v.setSource(QUrl('func.qml'))
  r = v.rootObject()

  print r.hello
  print r.property('stuff')['hello']

I get this output:

  <PySide.MetaFunction object at 0x10d8d7300>
  {u'length': 0.0, u'caller': None, u'callee': None, u'arguments': None,
u'name': u'hello'}

whereas I would hope for:

  <PySide.MetaFunction object at 0x10d8d7300>
  <PySide.MetaFunction object at 0x10d8d7300>
Comment 1 Hugo Parente Lima 2011-08-23 20:25:20 EEST
We need to investigate if this is possible, i.e. check what is returned inside
the QVariant when you do r.property('stuff')['hello'].

I'll mark the bug as valid and wait for further investigations, thanks!
Comment 2 Hugo Parente Lima 2011-08-31 17:22:10 EEST
Hi,

After further investigation this is what I found:

When you do:

r.hello

PySide doesn't find the attribute hello on r object then it searches into r
QMetaObject for something called "hello" and find the function because every
function declared in QML is a slot.

When you do:

r.property('stuff')

PySide calls the C++ method property() of Qt QGraphicsObject class which
returns a QVariant, the QML C++ API returns a QVariant holding a QVariantMap
translated to a dict by PySide.

So the problem is: I don't have how to know if this was a really QVariantMap or
a function, because Qt C++ API just return a QVariantMap for both, we would
interpret the QVariantMap and return a MetaFunction but this would also lead to
weird results if the property was really a dict not a function, so I'm marking
this bug as WONTFIX, but thanks for the report/suggestion it's just not
feasible to implement it due to Qt restrictions.
Comment 3 Hugo Parente Lima 2011-08-31 17:23:13 EEST
Created attachment 413 [details]
C++ version of the example
Comment 4 renato filho 2011-09-21 21:19:47 EEST
Release 1.0.7