An Introduction To KActions

Richard Moore, rich@kde.org

Introduction

Demonstrate the common KAction types, their uses and their appearance when plugged into different containers. Example creates one of each action type and shows how they work.

The Action Classes

KAction

   (void) new KAction( i18n( "&Perform Action" ), "fileopen", CTRL+Key_P,
                       object, SLOT( performAction() ),
                       actionCollection(), "perform_action" );

KToggleAction

   (void) new KToggleAction( i18n( "&Enable/Disable Something" ), "fileopen", Key_Space,
                             object, SLOT( setSomethingEnabled(bool) ),
                             actionCollection(), "enable_something" );

KActionMenu

KRecentFilesAction

   (void) new KRecentFilesAction( i18n( "&Recent Files" ), "fileopen", CTRL+Key_R,
                       object, SLOT( openURL(const KURL &) ),
                       actionCollection(), "open_recent" );

KSelectAction

Creating Common Actions Using KStdAction