Content copy from https://smartcash.freshdesk.com/support/solutions/articles/35000081814-how-to-export-all-private-keys-from-qt-wallet
Step 1. Open console windows in Desktop Wallet
Step2 . Just use "dumpwallet /path/to/dumpwallet.txt" in the QT Wallet Console
dumpwallet /path/to/dumpwallet.txt
Example here i dumpwallet to Desktop in Mac
P/s: in case you have encrypted Wallet before you need run this command before run dumpwallet
walletpassphrase "your pass phrase" 600
Nice! Thanks man!