4

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.

demonplus
  • 5,613
  • 12
  • 49
  • 68
xxx
  • 79
  • 2
  • 6

1 Answers1

3

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.

demonplus
  • 5,613
  • 12
  • 49
  • 68