0

In my table i am having 5 columns in common and adding some column on the fly (Depending on the input). when the process is reloaded all the column will be deleted and the default 5 columns is created and the other columns too. The script i am using for column deletion is as :

totalColumns = self.TBL_shotDetails.columnCount()
for index in xrange(totalColumns) :
    self.TBL_shotDetails.removeColumn(index)

When running this lines of code, only the first two columns are getting deleted. And the rest are not getting deleted. Can anyone suggest me how to do this.

  • In addiction to my answer, here is a difference between range and xrange http://stackoverflow.com/questions/135041/should-you-always-favor-xrange-over-range – Qwerty Mar 13 '13 at 12:04

1 Answers1

2

Did you check the value of index? The index is still incrementing. Column which had index 3 now replaces deleted column with index 2, but you continue on deleting incrementing index.

EDIT:
You might want to delete from 7 down to 0.

Qwerty
  • 24,727
  • 20
  • 99
  • 119