PDA

View Full Version : How can I do pixel image drawing with Python and QML?



CaCO3
27th August 2011, 20:19
I wrote some applications which do pixel drawing with a QPainter.
I am now wondering how I could port this to QML.

I searched the web quite a while, but couldnt find any examples how to paint from Python on a QML page.

On PyQt I did it like this:

class MyCanvas(QtGui.QWidget):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, xxx)
self.setGeometry(10, 180, 781, 241)


def paintEvent(self, event):
paint = QtGui.QPainter()
paint.begin(self)
paint.setPen(QtGui.QColor("gray"))
paint.setBrush(QtGui.QColor("black"))
paint.drawRect(0,0,780,240)
paint.end()

canvas = MyCanvas()
canvas.show()

This then draw directly on my QWidget.

So my question is, how would I be able to do something like this with QML?

khalidh
24th September 2011, 09:58
I am looking for exactly same solution. Please if you have manage to find the solution let us know.

Thank you

CaCO3
24th September 2011, 13:01
I am looking for exactly same solution. Please if you have manage to find the solution let us know.


Yes, I got it working.
I wrote a demo application: http://forum.meego.com/showthread.php?t=4412&highlight=angle

khalidh
25th September 2011, 12:04
That was great help!!!!

Thank you

Khalidh