You're asking for troubles by allocating widgets and layouts on the stack... It's not really safe, once a parent deletes a child allocated on the stack you'll get a crash.