Why do you have to restart just to set the orientation? I implement the same kind of setting and it takes affect immediately. If you haven't already, take a look at QSettings. I just called a method after I changed the orientation setting which set the appropriate attribute accordingly.
w.setAttribute(Qt::WA_Maemo5AutoOrientation, true);