This is technically fine, if a bit unclear.
The bool will be promoted to an int, so the result is well-defined. However, looking at that code I don’t instantly get the semantics you are trying to achieve.
I would simply write something like:
height = legendText->isEmpty() ? 0 : height;
This makes your intent far clearer.