[PyKDE] Is it possible to add QPushButton To QListView?

Dirk Reisnauer dirk.reisnauer at desys.de
Tue Mar 9 07:38:01 GMT 2004

On Fri, 5 Mar 2004 09:48:47 -0800 (PST), Peter Gordon <gordonp1 at yahoo.com> 

> Is it possible to add QPushButton (or QToolButton) to
> QListView with QListViewItem or any other way? I want
> to have one column with pusbutton.
> Also how can you control the background/foreground
> color of each row? I saw an article on Trolltech site
> using C++ but I do not know how to traslate it to
> Python.

To derive from the QListViewItem and overwrite the paintCell method.
So you can control the colors.

     def paintCell(self, p, cg, column, width, align):
         _qg = QColorGroup(cg)
         _qg.setColor(QColorGroup.Text, a_text_color)
         _qg.setColor(QColorGroup.Background, a_background_color)
         QListViewItem.paintCell(self, p, _qg, column,width, align)

The step must well-advised. Every insert or sort of rows call this method.

> Peter
> __________________________________
> Do you Yahoo!?
> Yahoo! Search - Find what you’re looking for faster
> http://search.yahoo.com
> _______________________________________________
> PyKDE mailing list    PyKDE at mats.imk.fraunhofer.de
> http://mats.imk.fraunhofer.de/mailman/listinfo/pykde

  The box said "Requires WinXP, W2k, or better," and so I installed Linux.

More information about the PyQt mailing list