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?
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?