Hi,
Can i keep validator for the QTableWidgetItem as we can assign validator for the line edit.
mukunda
Hi,
Can i keep validator for the QTableWidgetItem as we can assign validator for the line edit.
mukunda
You have to use a QLineEdit and put it over the QTableWidgetItem, (i.e. put the widget on the cell where you have your QTableWidgetItem) this can be done usingQt Code:
To copy to clipboard, switch view to plain text mode
Look at QStyledItemDelegate::createEditor() and QTableView::setItemDelegate() (and the related row/column versions). You can provide a custom editor, when required, for particular columns, rows, or the whole table and attach any validator you like.
I dont want to set the cell widget with line edits and set the validators to the lineedits.
Is there any direct way of setting the validators to the table widget items?
Read my last post. Using the delegate mechanism you create an editor widget only when editing is actually attempted. There is only the one QLineEdit with its validator. That widget goes away when the editing is finished.
Last edited by ChrisW67; 6th June 2011 at 23:25.
Bookmarks