Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 6

Qt-interest Archive, March 2002
Numeric chars in QTable


Message 1 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.

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 ]