Neverendingo (Talk | contribs) m (Text replace - "<code cpp>" to "<syntaxhighlight lang="cpp">") |
Neverendingo (Talk | contribs) m (Text replace - "</code>" to "</syntaxhighlight>") |
||
| Line 20: | Line 20: | ||
<syntaxhighlight lang="cpp"> | <syntaxhighlight lang="cpp"> | ||
widget->setToolTip(i18n("This widget does something.")) | widget->setToolTip(i18n("This widget does something.")) | ||
| − | </ | + | </syntaxhighlight> |
If the menu bars and tool bars are created using the [[../Action Pattern|action pattern]], the string used as tooltip is derived from the first argument | If the menu bars and tool bars are created using the [[../Action Pattern|action pattern]], the string used as tooltip is derived from the first argument | ||
| Line 28: | Line 28: | ||
action = new KAction(i18n("&Delete"), "editdelete", | action = new KAction(i18n("&Delete"), "editdelete", | ||
SHIFT+Key_Delete, actionCollection(), "del") | SHIFT+Key_Delete, actionCollection(), "del") | ||
| − | </ | + | </syntaxhighlight> |
Here it is also possible to assign a text which is shown in the status bar when the respective menu item is highlighted: | Here it is also possible to assign a text which is shown in the status bar when the respective menu item is highlighted: | ||
| Line 34: | Line 34: | ||
<syntaxhighlight lang="cpp"> | <syntaxhighlight lang="cpp"> | ||
action->setStatusText(i18n("Deletes the marked file")) | action->setStatusText(i18n("Deletes the marked file")) | ||
| − | </ | + | </syntaxhighlight> |
The API for "What's this?' help is very similar. In dialogs, use the following | The API for "What's this?' help is very similar. In dialogs, use the following | ||
| Line 45: | Line 45: | ||
"<li>Bar</li>" | "<li>Bar</li>" | ||
"</ul></qt>")) | "</ul></qt>")) | ||
| − | </ | + | </syntaxhighlight> |
For menu items, use | For menu items, use | ||
<syntaxhighlight lang="cpp"> | <syntaxhighlight lang="cpp"> | ||
action->setWhatsThis(i18n("Deletes the marked file")) | action->setWhatsThis(i18n("Deletes the marked file")) | ||
| − | </ | + | </syntaxhighlight> |
The invocation of khelpcenter is encapsulated in the | The invocation of khelpcenter is encapsulated in the | ||
| Line 58: | Line 58: | ||
<syntaxhighlight lang="cpp"> | <syntaxhighlight lang="cpp"> | ||
KToolInvocation::invokeHelp() | KToolInvocation::invokeHelp() | ||
| − | </ | + | </syntaxhighlight> |
This displays the first page with the table of contents. When | This displays the first page with the table of contents. When | ||
Languages: عربي | Asturianu | Català | Česky | Kaszëbsczi | Dansk | Deutsch | English | Esperanto | Español | Eesti | فارسی | Suomi | Français | Galego | Italiano | 日本語 | 한국어 | Norwegian | Polski | Português Brasileiro | Română | Русский | Svenska | Slovenčina | Slovenščina | српски | Türkçe | Tiếng Việt | Українська | 简体中文 | 繁體中文
KDE Architecture - Providing online help
Making a program easy and intuitive to use involves a wide range of facilities which are usually called online help. Online help has several, partially conflicting goals: on the one, it should give the user answers to the question "How can I do a certain task?", on the other hand it should help the user exploring the application and finding features he doesn't yet know about. It is important to recognize that this can only be achieved by offering several levels of help:
From the programmer's point of view, Qt provides an easy to use API for online help. To assign a tooltip to widget, simply use its setToolTip() method.
widget->setToolTip(i18n("This widget does something."))
If the menu bars and tool bars are created using the action pattern, the string used as tooltip is derived from the first argument of the KAction constructor:
action = new KAction(i18n("&Delete"), "editdelete", SHIFT+Key_Delete, actionCollection(), "del")
Here it is also possible to assign a text which is shown in the status bar when the respective menu item is highlighted:
action->setStatusText(i18n("Deletes the marked file"))
The API for "What's this?' help is very similar. In dialogs, use the following code:
widget->setWhatsThis(i18n("<qt>This demonstrates <b>Qt</b>'s" " rich text engine.<ul>" "<li>Foo</li>" "<li>Bar</li>" "</ul></qt>"))
For menu items, use
action->setWhatsThis(i18n("Deletes the marked file"))
The invocation of khelpcenter is encapsulated in the KToolInvocation class. In order to show the manual of your application, just use the static method:
KToolInvocation::invokeHelp()
This displays the first page with the table of contents. When you want to display only a certain section of the manual, you can give an additional argument to invokeHelp() determining the anchor which the browser jumps to.
Initial Author: Bernd Gehrmann