Hi Daniel, 2011/8/18 <[email protected]>: > 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 [email protected] http://lists.pyside.org/listinfo/pyside
