C
Constantly Distracted
I've just started PyQt programming and I've run into this little
problem. When I set the text of one cell in my table, all the other
cells fill with that value.
All I wanted to do was run a loop, printing in each cell the row and
column number.
Here's the code.
------------------------------
from PyQt4 import QtGui,QtCore
import sys
class mywindow(QtGui.QWidget):
def __init__(self,parent=None):
QtGui.QWidget.__init__(self,parent)
self.resize(700,700)
self.mytable=QtGui.QTableWidget(7,6,self)
self.mytable.resize(700,700)
def filltable(self):
items=QtGui.QTableWidgetItem()
for column in range(self.mytable.columnCount()):
for row in range(self.mytable.rowCount()):
items.setText("row: " + str(row) + " column: " +
str(column))
self.mytable.setItem(row,column,items)
app=QtGui.QApplication(sys.argv)
mainwin=mywindow()
mainwin.filltable()
qb.show()
app.exec_()
problem. When I set the text of one cell in my table, all the other
cells fill with that value.
All I wanted to do was run a loop, printing in each cell the row and
column number.
Here's the code.
------------------------------
from PyQt4 import QtGui,QtCore
import sys
class mywindow(QtGui.QWidget):
def __init__(self,parent=None):
QtGui.QWidget.__init__(self,parent)
self.resize(700,700)
self.mytable=QtGui.QTableWidget(7,6,self)
self.mytable.resize(700,700)
def filltable(self):
items=QtGui.QTableWidgetItem()
for column in range(self.mytable.columnCount()):
for row in range(self.mytable.rowCount()):
items.setText("row: " + str(row) + " column: " +
str(column))
self.mytable.setItem(row,column,items)
app=QtGui.QApplication(sys.argv)
mainwin=mywindow()
mainwin.filltable()
qb.show()
app.exec_()