Results 1 to 2 of 2

Thread: Qt WebEngine and Proxies

  1. #1
    Join Date
    Apr 2017
    Qt products

    Default Qt WebEngine and Proxies

    I have an application that has "Account" objects that store information such as cookies and a proxy used for the account. When I make a network request through QNetworkAccessManager for each of these accounts I have been using the QNetworkAccessManager setProxy() method just prior to making the request. I had originally tried to create a proxy factory for this, however I don't seem to have any control over the QNetworkProxyQuery object that gets passed into the factory methods, so no way to differentiate which "Account" a particular request is for since the url/port/QueryType, etc might be the same for multiple accounts. I didn't see any way to subclass QNetworkProxyQuery to pass around an "Account" pointer that I could use within the factory methods to know which proxy a particular request was for, since the creation of the QNetworkProxyQuery objects all happen in internal methods/classes.

    So I ended up with just using setProxy() as mentioned above, and that worked out just fine for my needs.

    However, now that I am also implementing in Qt WebEngine into my application, things are getting a bit more difficult. What I need to do is launch a particular QtWebEngineView/Page using the proxy an "Account" specifies. I have read and found out the WebEngine uses the applicationProxy to determine which proxy to use. So at first I thought I could just do a similar thing I've been doing with QNAM and just call setApplicationProxy() just prior to creating the WebEngineView/Page and calling load(). But I started digging into the source and found out that Chromium seems to periodically call the function OnLazyPoll() to get the current applicationProxy ( and if it has been changed since the last time it got polled, it seems it would change the proxy across all webviews that you would have loaded.

    This is a problem, since I need to maintain the proxy I have set when I loaded the view. So that threw out the idea of using setApplicationProxy(). The only solution I can think of at this point is to completely separate each created WebEngineView into a QProcess with it's own QApplication instance that I can use with setApplicationProxy(). I had originally wanted to make each WebEnginePage a tab in my main application, but going this route I don't think I can do it. Unless there is some IPC classes that can make each "tab" it's own process WITHIN the main running application (not a separate window).

    Any ideas/tips on what I can do to solve this problem would be appreciated.


  2. #2
    Join Date
    Jan 2006
    Warsaw, Poland
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits

    Default Re: Qt WebEngine and Proxies

    Each tab actually IS (or at least can be) a separate process but that's chromium's internal architecture and you have no influence on it. I don't think there is API exposed to do what you want.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.

Similar Threads

  1. HOW to embed IE core into QT WebEngine
    By DJW602 in forum Qt Programming
    Replies: 1
    Last Post: 5th August 2016, 09:54
  2. Questions about the download with WebEngine
    By MrCoder in forum Qt Quick
    Replies: 5
    Last Post: 16th May 2016, 08:52
  3. Printing WebEngine Pages
    By brixel in forum Newbie
    Replies: 2
    Last Post: 10th May 2016, 11:42
  4. Issues with Qfilesystemmodel proxies
    By Guett_31 in forum Qt Programming
    Replies: 0
    Last Post: 25th July 2013, 07:24
  5. Overriding Proxies
    By jdgrant in forum Qt Programming
    Replies: 0
    Last Post: 25th November 2011, 01:23

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.