add/remove window only when the window is shown/hidden

Task-number: QTBUG-34469

Change-Id: Id77cf738f96bb94582833f6734a2a491b01e1666
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>