[PyQt] stylesheets for custom classes and properties?

Florian Bruhin me at the-compiler.org
Tue Apr 11 07:41:35 BST 2017


Hi,

On Mon, Apr 10, 2017 at 11:30:23PM -0700, Patrick Stinson wrote:
> I looked in the docs but no dice. Are custom pyqt classes supported
> via Qt stylesheets? Hard to think how this would be possible?

I'm not sure if matching by class works, but I usually do this in
__init__:  self.setObjectName(self.__class__.__name__)

And then match on the object name, like here:
https://github.com/qutebrowser/qutebrowser/blob/master/qutebrowser/mainwindow/statusbar/bar.py#L92

Or do you mean styling a class with completely custom painting via
stylesheets? That's not possible as far as I know, but it's not in Qt
either.

> What about dynamic properties? This one seems more straightforward to
> implement.

See the same stylesheet - works with @pyqtProperty decorated properties,
but you'll need to re-set the stylesheet after changing it.

Also see: http://pyqt.sourceforge.net/Docs/PyQt5/qt_properties.html

Florian

-- 
http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc
         I love long mails! | http://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20170411/bc20dffa/attachment.sig>


More information about the PyQt mailing list