[PyQt] tableItem as a list

David Boddie david at boddie.org.uk
Tue May 15 00:45:56 BST 2007


On Wednesday 02 May 2007 02:30:46 +0200, Behnam Kamrani wrote:

> I'm writing this message desperately. Using qt (3.3.4), I have a table in a
> widget, and since it needed to Enabled/Disabled table cells, I used
> tableItems for it.
>
> To make it structural in my thinking, I used a list like
> self.myTable.tableItem = [ [ ] ]. This way, it became possible to save all
> tableItems in a list and reuse it. ie:
>
> for iRow in range(0, numberOfRows):
> self.myTable.tableItem.append( myTableItemClass)
>     for iCol in range(0, numberOfCols):
>      self.myTable.tableItem[iRow].append( myTableItemClass)
> ...
> ...

This all sounds reasonable, except that you're appending "myTableItemClass"
in each row then appending the same object in each column in every row.
Have I misunderstood what you're doing? Could you show us a more complete
example?

> But the problem arises when I redraw the table for several times (e.g. 16
> times). The GUI does NOT crash, however in output windows I get the
> following messages :
>
> QGVector::remove: Index -7 out of range
> QGVector::remove: Index -7 out of range
> QGVector::remove: Index -7 out of range
> ---  as the number of tableItems in the list ----
>
> I tried to empty out the list each time the table is redrawed without any
> success. Some attempts for example:
> self.myTable.tableItem = [ [ ] ]
> or
> del self.myTable.tableItem[ :]
> or
> del self.myTable.tableItem
> or
> del self.myTable.tableItem[ 0: 6]  (since myTable has 6 columns)

I'm confused. Are you appending items to the list each time the table is
redrawn?

David



More information about the PyQt mailing list