Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

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

    QtWebEngine
    1
    1
    402
    Loading More Posts
    • 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
      SandyMedical last edited by SandyMedical

      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 Reply Quote 0
      • First post
        Last post