I have seen the k_mnu.cpp code to see how they get it done. Here is the relative code... my question is... where did they get kapp from?
if (kapp->authorize("logout"))
insertItem(SmallIconSet("exit"), i18n("Logout \"%1\"...").arg(username), this, SLOT(slotLogout()));
void PanelKMenu::slotLogout()
{
QApplication::syncX();
kapp->requestShutDown();
}