Pregunta

There is a diagram which I have drawn with QPainter. How do I diaplay it in QML's Rectangle?

That diagram will get updated on the runtime.

¿Fue útil?

Solución

The question is a bit vague.

Do you have the diagram in a QImage or a QPixmap? Then you can use image providers to expose the diagram to QML, and draw it into a Image element.

Do you have the code that uses a QPainter to draw it, and want to make a QML element that uses such code? In that case, subclass QDeclarativeItem (in Qt Quick 1) or QQuickPaintedItem (Qt Quick 2), override their paint() methods and do the drawing there. You can then register the new type in the QML engine, so you can use a Diagram type in your QML files.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top