[PyKDE] Changing Color in QTable entries

Hans-Peter Jansen hpj at urpla.net
Tue Nov 12 15:20:01 GMT 2002


On Monday 11 November 2002 16:23, David Sathiaraj wrote:
> Hello QT folks:
>
> I have been trying to implement a GUI that uses the QTable and
> QTableItem methods.  I have a table of entries and
> I want to keep track of the changes I make to the table entries.
>
> Now I want to highlight the changed cells with a different color.  I
> sub-classed QTableItem and re-implemented the
> QTableItem::Paint method to change the color of the entries.  However, I
> see a quick flicker of color change and
> then the old white background seems to override it.  I believe before
> the color change is incorporated, garbage collection
> takes over and clears the colored objects created.   If anyone has
> encountered such a problem,  can you tell me how I could force the color
> of the
> changed items to persist?
>
> I have attached a small test snippet - The main process is coded in
> changeColor.py. Table.py is the code generated by Qt designer that is
> used by changeColor.py.  One can run changeColor.py to test it. The
> button 'show changes' should ideally color the items.

Hi David,

this depends on the EditType flag from the QTableItem. If you want to
use QTableItem.Always, you need also to reimplement createEditor() and
friends. Read QTableItem::EditType in FM. Try QTableItem.OnTyping, 
which hopefully does, what you want...

> Regards,
> David S.

Hth,
Hans-Peter




More information about the PyQt mailing list