Deductions & credits

I don't understand. How does a S corp distribute profits to its shareholders if not through a dividend? And if dividends are excluded from QBI deduction then what gives? that is what I am trying to understand.