【问题标题】:How to set User Agent in QtWebEngine QML application如何在 QtWebEngine QML 应用程序中设置用户代理
【发布时间】:2015-06-16 18:44:14
【问题描述】:

注意:我可以使用 QtWebView extension 在 QtWebKit QML 上做到这一点。这里我有兴趣使用QtWebEngine

我的简单测试应用程序

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
    }
}

如何传递不同的User Agent string

【问题讨论】:

    标签: qt qml qt5 user-agent qtwebengine


    【解决方案1】:

    我也对使用 QtWebEngine 感兴趣。我可以建议你使用 QtWebEngine 开发人员Trello

    您可以在 Todo for 5.5 中看到,这是currently under development,可能会在 5.5 中完成。

    【讨论】:

    • 确实很棒。谢谢你。
    【解决方案2】:

    从 Qt 5.5 开始,您可以设置 WebEngineProfile.userAgent 属性。

    【讨论】:

      【解决方案3】:

      //导入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"
          }
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-09-09
        • 2015-11-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-07-06
        • 2015-08-21
        • 2019-05-04
        相关资源
        最近更新 更多