[PyKDE] paint() and getting out of corners
Jim Bublitz
jbublitz at nwinternet.com
Fri Nov 22 17:12:01 GMT 2002
On 22-Nov-02 Rune Hansen wrote:
> As the title hints I've got serious problems trying to understand
> how to set color and font on a specific QListBoxItem. I would
> really appreciate a working example or at least better advice
> than RTFM ;-)
It looks like the easiest way would be to derive a class from
QListBoxText and overload QListBoxText.paint (QPainter). Modify the
properties of QPainter to get the fonts and colors you want.
class CustomListBoxText (QListBoxText):
def __init__ (self, <args>):
QListBoxText.__init__ (self, <args>)
def paint (p):
p.setFont (<args>)
p.setPen (<color>) # or create new pen(s) as needed
QListBoxText.paint (self, p)
For QPainter you'll have to RTFM though :) QPainter has methods for
setting the font and colors, and shouldn't be too difficult to
figure out.
If you can read C++ source, sometimes downloading the Qt source
from TrollTech can be helpful (and sometimes not).
Jim
More information about the PyQt
mailing list