Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change user agent in QWebEngineView

How to change the user agent in QWebEngineView? I know that for QWebView there is a way to do this but I didn't find the solution for the QWebEngineView.

like image 402
xxx Avatar asked Sep 11 '25 09:09

xxx


1 Answers

While constructing QWebEnginePage as one of the arguments you may specify QWebEngineProfile.

QWebEngineProfile - it is a class which contains different settings for your profile which can be shared between web pages.

For setting user agent you will need to use:

void QWebEngineProfile::setHttpUserAgent(const QString & userAgent)

http://doc.qt.io/qt-5/qwebengineprofile.html#setHttpUserAgent

QWebEngineProfile is available since Qt 5.5.

like image 56
demonplus Avatar answered Sep 14 '25 09:09

demonplus