Qt-interest Archive, March 2002
Numeric chars in QTable
Message 1 in thread
- Subject: Numeric chars in QTable
- From: SAJEESH MOHAN P <sajeeshmp@xxxxxxxxxx>
- Date: Thu, 14 Mar 2002 10:59:44 +0530
- Organization: NeST-India
- Return-receipt-to: SAJEESH MOHAN P <sajeeshmp@nestec.net>
- To: qt-interest@xxxxxxxxxxxxx
Hello,
I am facing a problem with QTable.What i need is to block all the
entries to the QTable except numericals.That is to prevent entering
alphabets in the cells of QTable.
Thanks in advance
Sajeesh
Message 2 in thread
> Hello,
>
> I am facing a problem with QTable.What i need is to
> block all the
> entries to the QTable except numericals.That is to prevent entering
> alphabets in the cells of QTable.
My guess is that you have to subclass QTableItem, override createEditor
and install an validator for that editor. Something like:
QWidget* YourTableItem::createEditor(){
QLineEdit *le = new QLineEdit(table()->viewport());
QDoubleValidator *dv = new QDoubleValidator(le);
le->setValidator(dv);
return le;
}
Take a look at the docs for QTableItem and QDoubleValidator for
more info...
--
[ signature omitted ]