Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arithmetic in numeric fields #74

Closed
N3Roaster opened this issue Mar 27, 2013 · 1 comment
Closed

Arithmetic in numeric fields #74

N3Roaster opened this issue Mar 27, 2013 · 1 comment

Comments

@N3Roaster
Copy link
Owner

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.

@N3Roaster
Copy link
Owner Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant