Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt WebEngine: External canvas JS library



  • I'm developing a Qt C++ GUI application and I would like to create a graph/plot using Qt WebEngine together with a external Javascript canvas library called plotly.js (website here)

    I tested this HTML + JS example source-code in my local browser. It works and display a simple 2D line chart.

    <html>
        <head>
            <!-- Plotly.js -->
            <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
          </head>
          
          <!-- Plots go in blank <div> elements. 
              You can size them in the plot layout,
              or give the div a size as shown here.
          -->
          <div id="tester" style="width:90%;height:250px;"></div>
          <script>
    
          TESTER = document.getElementById('tester');
          
          Plotly.plot( TESTER, [{
              x: [1, 2, 3, 4, 5],
              y: [1, 2, 4, 8, 16] }], { 
              margin: { t: 0 } }, {showSendToCloud:true} 
              );
          </script>
    </html>
    

    QUESTION:
    Is possible to show this canvas inside my Qt application?
    c3f4b54a-a6a9-47d4-8ce7-be9aa9061dfe-image.png

    Obs.: I know that Qt have some built-in charts and I'm already using it. But now I really need to use the charts from plotly.js for another reasons.


Log in to reply