Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. qt-webengine-javascript-failed-to-load-png-image

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

Scheduled Pinned Locked Moved Unsolved QtWebEngine
1 Posts 1 Posters 508 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SandyMedical
    wrote on last edited by SandyMedical
    #1

    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 ?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved