⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)

How to display QPixmap on a canvas element in a QWebView window?

  • I'm experimenting with QtWebKitBridge and have a basic testbed working. I have a Qt form with a button that loads a file from disc into a QPixmap and the embedded QWebView then loads that QPixmap into an <img> tag.. This much works.

    I drill into my webview:

    loadImage() is a javascript function that does the following to load the QPixmap into an img element:


    This works exactly as I'd expect.. The image that was loaded in the Qt context is displayed in the embedded webKit browser in "imageElement"

    But I don't want it on an image element, I want it on an html5 canvas element

    So if in my HTML, I also include:
    <canvas id="myCanvas" width="400" height="410"></canvas>

    Then how do I load my QPixmap into the canvas?

    I tried the following, but it crashes:--
    var context = document.getElementById("myCanvas").getContext("2d");


Log in to reply