Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Can we set specific Network proxy for QWebView
Qt 6.11 is out! See what's new in the release blog

[SOLVED] Can we set specific Network proxy for QWebView

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 9.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aashish.lg
    wrote on last edited by
    #1

    I am having one application where I am creating multiple QWebView objects.
    Since each QWebView object is loading different URL , and my network admin wanted to route the specific url through some proxy.
    I have one function QNetworkProxy::setApplicationProxy(), which will set the proxy for the entire app, i.e. all QWebView will use that proxy , but I wanted to use different proxy for different QWebView.

    Please advice how can we achieve this.
    Please help it is very urgent!!!!!

    1 Reply Last reply
    0
    • L Offline
      L Offline
      leon.anavi
      wrote on last edited by
      #2

      I think that the official "Qt documentation offers a solution for your request":http://qt-project.org/doc/qt-4.8/qnetworkproxy.html#details:

      bq. An alternative to setting an application wide proxy is to specify the proxy for individual sockets using QAbstractSocket::setProxy() and QTcpServer::setProxy(). In this way, it is possible to disable the use of a proxy for specific sockets using the following code:
      @ serverSocket->setProxy(QNetworkProxy::NoProxy);@

      http://anavi.org/

      1 Reply Last reply
      0
      • A Offline
        A Offline
        aashish.lg
        wrote on last edited by
        #3

        Thanks for your suggestion , but I am not using any QTCPSocket/QAbstractSocket/QTcpServer at all.
        I am just using QWebview to load my url. and we can't call this function(setProxy) on QWebView.

        so probably this is not the way to achieve this.
        Please share if you have any other thought

        1 Reply Last reply
        0
        • L Offline
          L Offline
          leon.anavi
          wrote on last edited by
          #4

          Have you seen "this thread at stackoverflow":http://stackoverflow.com/questions/6072574/how-do-i-manage-proxies-with-qt-qwebview?

          It highlights the documentation about "QWebPage":https://qt-project.org/doc/qt-4.8/qwebpage.html and method "setNetworkAccessManager":https://qt-project.org/doc/qt-4.8/qwebpage.html#setNetworkAccessManager:

          bq. Note: It is currently not supported to change the network access manager after the QWebPage has used it. The results of doing this are undefined.

          The recommended solution at "stackoverflow.com":http://stackoverflow.com/questions/6072574/how-do-i-manage-proxies-with-qt-qwebview to create QNetworkAccessManager, set up a proxy and then to pass it to the web page seems reasonable.

          http://anavi.org/

          1 Reply Last reply
          0
          • A Offline
            A Offline
            aashish.lg
            wrote on last edited by
            #5

            Thanks a lot leon!!!!!!!!!!!!

            You made my life really cool.
            I am being able to set the different proxy for different Qwebview inside a single application.
            your solution simply rockzz!!!!!!!!

            1 Reply Last reply
            0
            • L Offline
              L Offline
              leon.anavi
              wrote on last edited by
              #6

              [quote author="Ashish Mittal" date="1332916135"]Thanks a lot leon!!!!!!!!!!!!

              You made my life really cool.
              I am being able to set the different proxy for different Qwebview inside a single application.
              your solution simply rockzz!!!!!!!!
              [/quote]

              You are welcome :) I am glad that the issue was solved but please note that I got the idea from a thread at "stackoverflow.com":http://stackoverflow.com/questions/6072574/how-do-i-manage-proxies-with-qt-qwebview.

              http://anavi.org/

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved