I once had to repair a spare QP V headlight I was selling as part of the holding mechanism had dislodged. The mechanism was linked to the headlight elevation angle adjuster. It was a pain in the butt to fix as the fixing point needed pressure from the from lens area to push it back into place. I rigged some wire which I managed to loop around the back of the piece and pull. Popped it back into place. Took ages.
However, for that to happen, the headlight would need a serious knock. I hope and suspect it is something else in your case, but thought I should mention. In your case if both beams are jittering, it would be impossible for this to happen to both your headlights. However you can adjust the headlight elevation angle and I’d start by testing those first to see what happens.
You may need to remove the front plastic panels and inspect the fixings too.