Code like that exists, you just need to make the "f" a capital letter (moveToFront instead of moveTofront).
If you don't need to call any function specific to MenuBar then you can skip the cast to MenuBar and have code that works for any type of widget:
tgui::Widget::Ptr widget = gui->get("MenuBar");
widget->moveToFront();