Well, what I ended up doing is this: In QML:
Rectangle { signal my_func(variant args) [...] MouseArea { [...] onClicked: my_func([1,2,3]) } } and in Python: def stuff(a): print a [...] view.rootObject().my_func.connect(stuff) which works pretty well for my purposes. It'd be more convenient to have a variable list of args, but I'm happy enough. =) Thanks for the ideas! dan ---- Daniel Ashbrook, PhD Senior Researcher, New Mobile Forms and Experiences Nokia Research Center Media Technologies Lab, Santa Monica daniel.ashbr...@nokia.com On Aug 18, 2011, at 12:19p, ext Thomas Perl wrote: > Hi Daniel, > > 2011/8/18 <daniel.ashbr...@nokia.com>: >> I'd like to make a slot in my pyside code that accepts any arguments so I >> can call it in a variety of situations from QML. I was hoping that something >> like this would work: >> [...] >> view.rootContext().setContextProperty('test', view) >> [...] >> @Slot(object) >> def stuff(self, o): >> print o >> [...] >> test.stuff('hello') >> test.stuff([1,2,3]) >> [...] >> Ideally, there would some sort of variable arguments I could use so that I >> could have 'def stuff(self, *args)' and call in QML 'test.stuff(1,2,3)'. >> >> Any advice? > > Does Qt have variable-argument slots? I ask because I'm not sure if > it's technically feasible. I only found a thread from 2009 that says > it is not possible: > > http://www.qtcentre.org/threads/26014-slot-with-variable-arguments > > At least using the [1,2,3] as QScriptValue and then doing some > "unpacking" of this on the Python side should be possible. > > Another possibility I see is to subclass QScriptValue and overwrite > the call() method on it: > > http://doc.qt.nokia.com/latest/qscriptvalue.html#call > > I have not tested this myself, and I wouldn't be surprised if it > needed some fixes in the PySide engine - just listing some > possibilities :) > > HTH. > Thomas _______________________________________________ PySide mailing list PySide@lists.pyside.org http://lists.pyside.org/listinfo/pyside