When in the Q or in any government quarters permanantly, you are not eligable to receive BAH. If you are in a place out in town and are allowed to live out there (by your command), then you are entitled to BAH, even when deployed on the ship.
The trick is working a PCS move, so that you get DLA (stands for "Wad of Cash") and still can stay in the Q. You have 60 days till you have to move out and still get DLA. However, most of the Q's I've been in have not been all that great (at least the transient ones), so I wanted to move out as soon as possible.