I write a table class which can reload items after a resize event.
But the the reloadControls() method is non-reentrant
After i resize the table to a smaller size, two reloadControls() confilcts. The controls loaded twice,
So ,how can i prevent this situation, Cos when you resize a window,resizeEvent are raised several times.
def resizeEvent(self,event):
if self.rowCount()!=0:
self.reloadControls()
def reloadControls(self):
self.clear()
if self.rowCount()==0:
for key in self.c_dict:
self.addItem( self.c_dict[key])
class ClientTableWidget(QtGui.QTableWidget):
def resizeEvent(self,event):
if self.rowCount()!=0:
self.reloadControls()
QtGui.QTableWidget.resizeEvent(self, event)
def reloadControls(self):
self.clear()
if self.rowCount()==0:
for key in self.c_dict:
self.addItem( self.c_dict[key])
To copy to clipboard, switch view to plain text mode
sample images:
after loading
after enlarging the window size, items' number did not change, there is no conflict
but when i resize the window to a smaller size, items loaded twice :
Bookmarks