[PyQt] how to set accept-language

Florian Bruhin me at the-compiler.org
Thu May 22 11:05:23 BST 2014


* Peter Irbizon <peterirbizon at gmail.com> [2014-05-22 11:31:11 +0200]:
> Hi
> I have this browser code and I am trying to put accept-language header. I
> have no idea how to do it in this code. Can you help me what/where to add
> it? Many thanks
> 
> [...]

You need to subclass QNetworkAccessManager to add the header,
something like this:

    class NetworkManager(QNetworkAccessManager):
        def createRequest(self, op, req, outgoing_data):
            req.setRawHeader('Accept-Language'.encode('ascii'),
                             'en-US,en'.encode('ascii'))
            return super().createRequest(op, req, outgoing_data)

And then use setNetworkAccessManager() on your QWebPage.

Florian

-- 
() ascii ribbon campaign - stop html mail    www.asciiribbon.org
/\ www.the-compiler.org  | I love long mails http://email.is-not-s.ms/
No one can guarantee the actions of another. -- Spock, "Day of the Dove", 
stardate unknown 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20140522/0ef1d567/attachment.sig>


More information about the PyQt mailing list