Weird issue with WebView and Whatsapp web
Unsolved
QML and Qt Quick
-
Hello! I'm trying to display the whatsapp web website (web.whatsapp.com) in a webview element, Qt6. To do so, I changed the user agent, like this:
import QtQuick import QtQuick.Controls import QtWebEngine import QtWebView ApplicationWindow { visible: true width: 800 height: 600 WebView { id: webView anchors.fill: parent httpUserAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36" onLoadingChanged: { deleteAllCookies() httpUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36" } Component.onCompleted: { // Load example.com webView.url = "https://web.whatsapp.com/"; // webView.url = "https://www.whatismybrowser.com/"; } } }
and then I run it with
qml6 main.qml
the strange thing is that it works until the page is reloaded. right after being run, it displays the QR code, and you can log in and view and send messages perfectly. But if I right click on the page and hit "reload", it imediately displays the "you must use Chrome 60+" message. I tried loading https://www.whatismybrowser.com/ to show my useragent, and even after reloading it still is the one I set. Why is whatsapp behaving like this? how can I solve this?