How does LED matrix circuit work in the following example?
... whilst Q1 - Q7 must be floating.


No they don't. They simply must not provide a voltage that will light the LEDs to any real extent. Pulling them low, and therefore the anodes to 0V, suffices.