in a way yes and no. capital gains are not eligible for the QBI deduction.
the tentative QBI deduction is computed based on the S-Corp. there's a second tentative calculation based on 20% of taxable income reduced by net L-T Capital gains and qualified dividends.
the lesser of the 2 tentative calculations is your QBI deduction.
in addition, your QBI deduction can be affected by taxable income, marital status, whether the S-Corp is a Specified Service Trade or Business, QBI loss carryover, Passive Activity Loss rules, etc.