PDA

View Full Version : Passing a QPainter to a QtScript



poco
10th November 2012, 20:32
Hi,

I am trying to make some painting inside my QtScript. My main issue is to be able to transfer a QPainter object from the C++ code to the QtScript I am executing. It would be trivial if QPainter was a QObject, but since it is not, I am looking for an easy way to make QPainter’s method accessible from inside the QtScript (e.g. QPainter::fillRect(), QPainter::setBrush()). Is there any easy way to do it? I would like avoiding to create by hand the QPainter wrapper and registering myself all the available methods. It seems someone has already done it, but I cannot find a nice C++ code.

https://qt.gitorious.org/qt-labs/graphics-dojo/blobs/master/barchart/barchart.qs

http://lists.kde.org/?l=kde-commits&m=125935572930177&w=2 (code in /plasma/scriptengines/javascript/simplebindings wraps QPainter by hand, hardcore!)

Thanks!

pkj
11th November 2012, 03:51
What you need is Qt Script Bindings generator. It has a license problem though. GPL. But you can always look at the generated code which introduces the classes to script and hand code yourself.