e.g.: ./bitcoin-qt --choosedatadir
Or as mentioned by ranochigo,
For bitcoin-qt's datadir, it's selected in the welcome screen when Bitcoin Core (GUI) couldn't find the previously set datadir or an existing datadir in the default paths which is %appdata%/bitcoin (will look here first) and %localappdata%/bitcoin (will create here if the default is selected) in v28.0.
Alternatively, if you set the above to the default datadir, you can paste the "bitcoin.conf" file there and type/uncomment the datadir=
The latter "alternative" works in bitcoind and bitcoin-qt while the former only works in bitcoin-qt (GUI).