PyQt QTableItem inheritance...
Mike Meyer
mwm at mired.org
Wed Apr 2 13:18:36 EST 2003
Phil Thompson <phil at river-bank.demon.co.uk> writes:
> On Tuesday 01 April 2003 5:31 pm, Mike Meyer wrote:
> > I've already tried posting this to the pyKDE mail list, and gotten no
> > response.
> >
> > I'm trying to create an item in a QTable that uses the
> > QDoubleValidator on the input edit field. The only way I can see to do
> > this is subclass QTableItem, and override createEditor with a method
> > that sets the validator, like so:
[code elided]
> > While I get the output from __init__, I never see the output from
> > createEditor. Any help would be appreciated.
>
> A small but complete example would help.
The rest of it is biolerplate, but here it is.
<mike
import sys
from qt import *
from qttable import *
class Float_Field(QTableItem):
def __init__(self, table, data):
print "Creating float field."
QTableItem.__init__(self, table, QTableItem.OnTyping, str(data))
def createEditor(self):
print "createEditor"
editor = QLineEdit(self.text(), self.table().viewport())
self.connect(editor, SIGNAL("textChanged(QString &)"),
self.table(), SLOT("doValueChanged"))
editor.setValidator(QDoubleValidator(self))
return editor
app = QApplication(sys.argv)
table = QTable(1, 1)
table.setItem(1, 1, Float_Field(table, "12.34"))
app.setMainWidget(table)
table.show()
app.exec_loop()
--
Mike Meyer <mwm at mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
More information about the Python-list
mailing list