[PyKDE] paint() and getting out of corners

Rune Hansen rune.hansen at viventus.no
Fri Nov 22 23:45:00 GMT 2002


Hi Jim, thanks for the code. This is in fact the exact same code I've
been struggling with for some time now(good to know I'm not totally lost
:-). According to the C++ examples I gather that  the class should be
initialized like this:

class CustomListBoxText(QListBoxText):
	def __init__(self,qlistbox_instance,qlistboxitem_text,<args>):
		QListBoxText.__init__(self,qlistbox_instance,qlistbox_text)

	def paint(self,<args>):
		...

No matter how I shuffle this my app always segfaults on calling paint()
I'm using stock RedHat 8.0 pyQt-3.3.2. I will try to compile the latest
& greatest pyQt tomorrow to see if it the segfault goes away.

thanks again

/rune

On Fri, 2002-11-22 at 16:56, Jim Bublitz wrote:
> 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
> 
> _______________________________________________
> PyKDE mailing list    PyKDE at mats.gmd.de
> http://mats.gmd.de/mailman/listinfo/pykde
-- 
Rune Hansen <rune.hansen at viventus.no>




More information about the PyQt mailing list