zabumba
zabumba

Reputation: 12412

How to set User Agent in QtWebEngine QML application

NOTE: I was able to do that on QtWebKit QML using the QtWebView extension. Here I am interested in using QtWebEngine.

My simple test application

import QtQuick 2.1
import QtQuick.Controls 1.1
import QtWebEngine 1.0

ApplicationWindow {
    width: 800
    height: 600
    color: "lightgray"
    visible: true
    WebEngineView {
        id: webview
        url: "http://stackexchange.com/"
        anchors.fill: parent
    }
}

How do I pass a different User Agent string?

Upvotes: 3

Views: 4018

Answers (3)

chsword
chsword

Reputation: 2062

// import QtWebEngine 1.4

WebEngineView {
    id: webview
    url: "http://stackexchange.com/"
    anchors.fill: parent
    profile:  WebEngineProfile{
        httpUserAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1"
    }
}

Upvotes: 3

kkoehne
kkoehne

Reputation: 1186

From Qt 5.5 onwards, you can set the WebEngineProfile.userAgent property.

Upvotes: 1

Yukarin
Yukarin

Reputation: 64

I'm interested in using QtWebEngine too. And I can suggest you use QtWebEngine developers Trello.

As you can see in Todo for 5.5 this is currently under development and may be done in 5.5.

Upvotes: 1

Related Questions