[PyKDE] QTableITem Validator
Christof Baur
cbaurtx at netzero.com
Sat Aug 17 13:31:00 BST 2002
Why does this python code not work ?
I use Qt3.03, Python 2.2 and pyqt 3.0 (I am not 100% sure about the PyQt
version)
Please send your comments also to cbaurtx at netzero.com. Thanks.
import sys
from qt import *
from qttable import *
class Test(QWidget):
def __init__(self,parent = None,name = None,fl = 0):
QWidget.__init__(self,parent,name,fl)
if name == None:
self.setName("TestValidator")
self.resize(733,513)
self.setSizePolicy(QSizePolicy(0,0,0,0,self.sizePolicy().hasHeightForWidth()))
self.setMaximumSize(QSize(790,544))
f = QFont(self.font())
self.setFont(f)
self.setCaption(self.trUtf8("TestValidator"))
self.Item1 = []
self.Table1 = QTable(self,"Table1")
self.Table1.setGeometry(QRect(35,15,616,416))
self.Table1.setFrameShape(QTable.NoFrame)
self.Table1.setFrameShadow(QTable.Plain)
self.Table1.setLineWidth(0)
self.Table1.setNumRows(4)
self.Table1.setNumCols(4)
self.Table1.setShowGrid(1)
self.Item1.append ( IntTableItem(self.Table1,1,""))
self.Item1[0].setText("123")
self.Table1.setItem(1,1,self.Item1[0])
class IntLineEdit (QLineEdit):
def __init__(self,parent = None,min = - 32000,max = 32000):
QLineEdit.__init__(self,parent)
self.setValidator(QIntValidator(min,max,self))
class IntTableItem(QTableItem):
def createEditor(self):
IntLineEdit(self.table().viewport(),-5000,5000)
def setContentFromEditor (createEditor):
self.setText (IntLineEdit().currentText())
if __name__ == "__main__":
a = QApplication(sys.argv)
QObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()"))
w = Test()
a.setMainWidget(w)
w.show()
a.exec_loop()
More information about the PyQt
mailing list