@Johnsonq said in Qt6 QWebEngine Plotly js: Uncaught Error : Something went wrong with axis scaling:
I.m using Qt 6.6.3, VS 2022, python 311 to plot something like 3D image. When I create QWebEngineView object like
ui.setupUi(this); webEnginePlot = new QWebEngineView(tabPlot); webEnginePlot->setObjectName("webEnginePlot"); webEnginePlot->setUrl(QUrl(QString::fromUtf8("about:blank")));MainWindow include
[ MenuBar ]
[QDockWidget QStackedWidget]QDockWidget on the left, QStackedWidget on the right. QDockWidget include QTreeView, QStackedWidget include QWebEngine
Question 1: Why the whole surface flashing(or hide, or white screen) 1 or 2 seconds? I found out it is loading QtWebEngineProcessd.exe
When I try to new QWebEngineView() before QTreeView init, nothing wrong. And when I init QTreeView first, then new QWebEngineView(), and the whole soft began to flashing(or hide, or white screen) to loading the QtWebEngineProcessd;
Question 2: I use C++ PythonAPI to draw a plot using plotly, and come out a file like a.html, and then I load the html file with QWebEngineView, and it showed up "js: Uncaught Error: Something went wrong with axis scaling"
QUrl localUrl = QUrl::fromLocalFile(htmlFile); ui.webEnginePlot->setUrl(localUrl); ui.webEnginePlot->show();But when I enter the QWidget and click my button to draw it again, and it works. Why when initializing, it will report an error?
How to solve the problem. Help me please!
The flashing or white screen issue when initializing QWebEngineView is likely due to the time it takes to load the QtWebEngineProcessd.exe. To avoid this, try initializing QWebEngineView before the QTreeView, as you’ve noticed it prevents the flashing. For the axis scaling error when loading the plotly HTML file, this might be due to the JavaScript not fully executing during the initial load. To resolve this, ensure that the HTML and its resources are fully loaded before rendering. You can also try reloading the page after a short delay or implement a callback function to reattempt drawing after the first load.