[PyQt] Properties in PyQt5
me at the-compiler.org
Wed Sep 24 05:37:58 BST 2014
* Glenn Ramsey <gr at componic.co.nz> [2014-09-24 16:03:30 +1200]:
> I have a dialog that has been created in Qt Designer and I would like to
> be able to set a red border on a QLineEdit based on its contents (or lack thereof).
> Below is what I have tried, based on the PyQt4 version in Mark Summerfield's
> book "Rapid GUI programming with Python and Qt", but it doesn't work.
It'd be useful if you said which page/snippet so I could take a look
at that as well ;)
> What have I done wrong here?
AFAIK you need to call setStyleSheet again after a property changed.
I do something like this (from memory, untested):
STYLESHEET = """
_error = False
def __init__(self, parent=None):
def error(self, val):
if self._error == val:
# Updating the stylesheet is rather expensive so we want
# to avoid it if it's unnecessary
self._error = val
http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
GPG 0xFD55A072 | 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: not available
Size: 819 bytes
Desc: not available
More information about the PyQt