[PyKDE] Aligning Text in a Table
Bob Parnes
rparnes at megalink.net
Fri Jun 27 16:55:01 BST 2003
Hello,
Sorry for posing trivial questions, but I do not understand how to use
paintCell. Attached is a demo to right-align text in a table cell.
There is no error message, but the code is ignored. So I assume that I
misinterpreted the documentation.
Thanks for any help.
bp
--
Bob Parnes
rparnes at megalink.net
-------------- next part --------------
#!/usr/bin/env python
import sys
from qt import *
from qttable import QTable
class Form1(QWidget):
def __init__(self,parent = None,name = None,fl = 0):
QWidget.__init__(self,parent,name,fl)
if not name:
self.setName("Form1")
self.table = QTable(self,"table")
self.table.setGeometry(QRect(50,60,335,104))
self.table.setNumRows(3)
self.table.setNumCols(3)
row = col = 1
r = self.table.cellRect(row,col)
p = QPainter(self)
p.drawText(r,Qt.AlignRight,'test')
selected = 1
self.table.paintCell(p,row,col,r,selected)
self.languageChange()
self.resize(QSize(458,258).expandedTo(self.minimumSizeHint()))
def languageChange(self):
self.setCaption(self.tr("Alignment Test"))
if __name__ == "__main__":
a = QApplication(sys.argv)
QObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()"))
w = Form1()
a.setMainWidget(w)
w.show()
a.exec_loop()
More information about the PyQt
mailing list