0
votes

Based on a previous question, I am using the QDoubleValidator class every time a cell is changed in a QTableView. Is there any way to use a combination of classes when checking the input?

For example I would like to have it that '3m' could be a valid input, where I can parse the certain value 'm' and convert the float into another float, eg 3000000. I would also like to be able to check for some other types of inputs.

This is my current Item Delegate;

class FloatDelegate(QItemDelegate):
    def __init__(self, parent=None):
        QItemDelegate.__init__(self, parent=parent)

    def createEditor(self, parent, option, index):
        editor = QLineEdit(parent)
        editor.setValidator(QDoubleValidator())
        return editor

I was unable to find something regarding the setValidator and how to handle a combination of Validator classes and how to process their inputs.

Thanks!

To perform this task you can build your custom validator to create a class that inherits from QValidator and overwrites the necessary methods. Another option is to use a QRegExpValidator and pass a regex that validates your entry, as your validation rules are not very clear I could not help you, I recommend trying one of those solutions and also place all the rules you want to use.eyllanesc
Ok, thank you. I will try to build something through QRegExpValidator.jim mako