Re: Subclassing a Qt non-QObject class

Phil Thompson <[email protected]>
Newsgroups gmane.comp.python.pyqt-pykde
Message-ID <[email protected]>
On 10/05/2019 02:50, Wallboy wrote:
> Hello,
> 
> I'm working with QNetworkCookieJar and QNetworkCookie in PyQt5. I would 
> like
> a custom QNetworkCookie class to add some additional attributes and 
> methods
> of my own.
> 
> I would like it so that when I insert cookie/s into the 
> QNetworkCookieJar
> and retrieve them later from the cookie jar, they would return my 
> custom
> subclass instance. However it seems when I insert a cookie instance of 
> my
> subclass into the jar, the subclass information is lost later on when I
> retrieve the cookies from the jar.
> 
> Is this because QNetworkCookie is not a QObject? I don't know the inner
> details of how the PyQt bindings work when converting classes from 
> PyQt->Qt
> and vice versa.
> 
> Is there a way I could achieve what I want in PyQt?

The issue isn't whether the class is a QObject or not, it is how the 
instance is passed - a pointer or a const reference. In this case it is 
a const reference so the jar takes a copy of the cookie and it can only 
copy what it knows about, ie. the base QNetworkCookie. It wouldn't work 
in C++ either.

Phil
_______________________________________________
PyQt mailing list    [email protected]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.