c++ – Evaluation of logical expressions given as a string

Question:

I am trying to implement input filtering. I want to make it so that the user enters a logical expression like (x > 100 && x < 120) || x ==42 . In the code, x will be replaced with a specific constant. Actually the question is how to calculate it? In principle, QScriptEngine::evaluate() copes well with this task, but pulling an entire Qt Script into a project for the sake of one line of code is very cool, in my opinion.

In short, is it possible to somehow do without Qt Script, and at the same time not write your own parser from scratch?

Answer:

The muParser library works great with Qt, even with variables and functions.

Scroll to Top