Skip to content


Arithmetic in numeric fields #74

N3Roaster opened this Issue · 1 comment

1 participant


Numeric entry fields should work like table cells that expect numeric data. That is, it should be possible to type something like 2+2 into the field and have that evaluated to 4. The edit data will need to be preserved separate from the display value, but it does not need to be persisted in the database.


The way this is done in tables takes advantage of the fact that behind the display is a model with multiple roles. That doesn't exist for QLineEdit, but if we're willing to discard the notion of preserving the original expression, it's very simple to introduce this functionality through the abuse of QValidator by having the fixup() method evaluate the script. In order to detect if the output is valid we can chain another validator on and use the validate() method to return Acceptable if the other validator returns the same, otherwise returning Intermediate. It probably isn't worth the effort to determine if the input can't possibly be valid JavaScript.

@N3Roaster N3Roaster added a commit that closed this issue
@N3Roaster Fixes #74 3c85ba8
@N3Roaster N3Roaster closed this in 3c85ba8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.