Probably involved in the osmoprotection via the biosynthesis of trehalose. Catalyzes the transfer of glucose from UDP-alpha-D-glucose (UDP-Glc) to D-glucose 6-phosphate (Glc-6-P) to form trehalose-6-phosphate. Acts with retention of the anomeric configuration of the UDP-sugar donor