Painting on top of QQuickView

  • Is it at all possible to paint (using QPainter) on top of (i.e. like an overlay) a QQuickView?

    I have a QML OSM map plugin loaded into a QWidget and I would like to draw on top of this using QPainter (rather than using QML). Is this achieveable?

    There appears to be no paintEvent or equivalent available when sub-classing QQuickView

  • Moderators

    You can create a transaprent QQuickPaintedItem that stretches over your whole QML window, and paint there.

    Just keep in mind that painting with QPainter is slower than with QML or OpenGL.

  • @sierdzio Thanks for your comments. Unfortunately I don't think what I ultimately want to do is possible due to the way QML and the QQuickPaintedItem is implemented.

    Basically, I have a 3rd party COM object which draws nautical charts. My existing QWidget application allows me to draw these charts in the paintEvent where I capture the winId of the QWidget and pass it to the BeginPaint/EndPaint functions ready for painting this 3rd party chart.

    The act of obtaining the winId in a QQuickPaintedItem causes a lot of issues and results in the underlying QML not being rendered.

    I've managed to implement this another way and it works so far.

Log in to reply