qt-webengine-javascript-failed-to-load-png-image



  • My work Environment : Qt 5.8 MSVC2015 64bit, Windows 7 64 bit, Web engine, JavaScript.

    In in QT code i am loading image, converting data into QByteArray & transfering back to JavaScript. So javaScript can render image.

    But Why JavaScript failed to load .png images, any clue what I am missing here ?

    QT .h file code :

    Q_INVOKABLE QByteArray GetTile();
    

    QT .cpp file code :

    QByteArray ExportedObject::GetTile()
    {
    QByteArray arr;
    QFile imageFile("D:\\2.png");
    arr = imageFile.readAll();
    imageFile.close();
    return arr;
    }
    

    JavaScript code :

    var myRetValue;
    window.interface.GetTile(function(returnValue) {
           myRetValue = returnValue;
    
            return returnValue;
    
    });
    

    alert(myRetValue) ///Why myRetValue always NULL ?
    document.getElementById("ItemPreview").src = "data:image/png;base64," + myRetValue ; // Why it failed to load image ?


Log in to reply