Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QWebEngineView double page load on HTML submit
PSI_lbc last edited by
I have a Form for processing purchases. It used to use a QWebView which is or is going to be deprecated. I updated to the latest Qt/Creator 5.7.1 in order to use the QWebEngineView..which is the QWebView replacement.
Creator does not have a QWebEngineView widget to just drop on a from, so a QWidget is added and then promoted to a QWebEngineView with an object name of webView.
The purpose of the view is to load a local html file that will transfer control to a https card processing portal on a submit button press.
I do the initial load of the QWebEngineView by doing the following in the ui’s showEvent()..
baseurl = QUrl::fromLocalFile(QApplication::applicationDirPath() + HELPDIR + buyfile);
ui->webView->load( baseurl );
This works. The buyfile which is simple HTML format loads and is displayed on the ui. I track the events firing with qDebug()
on_webView_urlChanged( url )
on_webView_loadFinished( bool ok )
At the point all is good.
There is a submit button in the HTML file that is used to send data to the card processing server..looks something like this..
<FORM METHOD='POST' ACTION="https://secure.cardprocessing.com/buynow">
<INPUT type=submit value="Buy Now!"></FONT>
<INPUT type=hidden name="vendor” value=“123456789”>
<INPUT type=hidden name="homepage" value="http://www.mywebpage.com">
<INPUT type=hidden name="showaddr" value="1"> <!--DO NOT ALTER-->
<INPUT type=hidden name="1-desc" value=“what is being purchased“>
<INPUT type=hidden name="1-cost" value=“19.95">
<INPUT type=hidden name="1-qty" value="1">
<INPUT type=hidden name="ret_addr" value="http://www.mywebpage.com/Reply/h-PurchaseOK.html">
When the Submit “But Now” button gets pressed, the webView fires the urlChanged signal but instead of going to the https://secure.cardprocessing.com/buynow url in the Submit button it FIRST reloads the page it’s already on THEN pauses 1-2 seconds THEN throws a weird error
js: Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/. THEN finishes loading the CC processing url.
THEN it goes to the CC processing url and loads that page correctly.
The Submit button url transfer is the only time there is a same page url reload.
IDK, but this seems like a BUG in the QWebEngineView. Is HTML code not supposed to be used in a QWebEngineView?