How to record a Qt5 application window with minimal to zero CPU overhead on Windows or Linux?

In the end, the only zero-overhead solution seems to be to use the HDMI output to connect to an external recording device, such as a laptop or a dedicated video capture box, and then use the "duplicate screen" mode.