[PyKDE] Problems with QTable
Rouxle Stegmann
rouxles at adsmr.co.za
Tue May 15 10:18:35 BST 2001
Hi,
I am a new user of PYQt and have been experiencing some problems
implementing a QTable.
When I call the setItem on QTable I run into all sorts of problems, eg:
- The following statements
item = QTableItem (self.CounterTable, QTableItem.Always,
QString('Hello'))
self.CounterTable.setItem (i,0,item)
causes and application error:
An application error has occurred ... Exception:access violation
- The same statements with a different edit type (Never) are executed, but
no text is displayed for the item
and it is still possible to edit the field.
item = QTableItem (self.CounterTable, QTableItem.Never,
QString('Hello'))
self.CounterTable.setItem (i,0,item)
- Using the setText in stead of the setItem function seems to work well, but
I have a requirement to change the edit type.
I am using the following:
- Windows Nt 4.0
- Python 2.0
- PyQt 2.2
Can anybody help me?
Thanks
Rouxle
Program follows:
import sys
from qt import *
class ToteForm(QDialog):
def __init__(self,parent = None,name =
None,modal = 0,fl = 0):
QDialog.__init__(self,parent,name,modal,fl)
if name == None:
self.setName('ToteForm')
formWidth = 527
self.resize(formWidth,250)
self.setFixedWidth(formWidth)
self.setMouseTracking(0)
self.setCaption(self.tr('Tote'))
vbox = QVBoxLayout(self)
vbox.setSpacing(6)
vbox.setMargin(11)
tableNumRows = 10
tableNumColumns = 5
tableHorizontalWidth = 504
self.CounterTable = QTable(self,'Table')
self.CounterTable.setGeometry(QRect(40,100,tableHorizontalWidth,256))
self.CounterTable.setFixedWidth (tableHorizontalWidth)
self.CounterTable.setMouseTracking(0)
self.CounterTable.setVScrollBarMode(QTable.Auto)
self.CounterTable.setHScrollBarMode(QTable.AlwaysOff)
self.CounterTable.setNumRows(tableNumRows)
self.CounterTable.setNumCols(tableNumColumns)
for i in range(tableNumRows):
#item = QTableItem (self.CounterTable, QTableItem.Always,
QString('Hello'))
item = QTableItem (self.CounterTable,
QTableItem.Never, QString('Hello'))
self.CounterTable.setItem (i,0,item)
print
self.CounterTable.item(i,0).editType()
print self.CounterTable.item(i,0).text()
for i in range(tableNumRows):
self.CounterTable.setText(i,1,'Goodbye' )
vbox.addWidget(self.CounterTable)
if __name__ == '__main__':
a = QApplication(sys.argv)
QObject.connect(a,SIGNAL('lastWindowClosed()'),a,SLOT('quit()'))
w =
ToteForm()
a.setMainWidget(w)
w.show()
a.exec_loop()
More information about the PyQt
mailing list