PDA

View Full Version : How to set Validator for individual cell in QTable



raghvendramisra
1st September 2008, 16:14
Hi,
i want to set validator for Individual cells in a Qtable.

I tried using setValidator function() but using it gave an error.


How can i set validator for cell so that it can take only "T" & "R" as input.

thanks

regards
Raghvendra

spirit
1st September 2008, 16:29
I think you can reimplement this method
http://doc.trolltech.com/3.3/qtableitem.html#createEditor, e.g. create QLineEdit and set needed validator and then return it.

raghvendramisra
4th September 2008, 12:03
Since the default editor type is QLine Edit for a QTable i used the following code
to implement the validator for a QTable


QRegExp rx( "(T|R|X|N)" );
QValidator* validator = new QRegExpValidator( rx, this );
QLineEdit *t = new QLineEdit(table1->viewport());
t->setValidator(validator);

But this also didn't solved the problem.

Plz tell me where is the problem.

Regards

Raghvendra

jpn
13th September 2008, 16:51
Where did you place that piece of code? Inside the function proposed by spirit or somewhere else?