Neverendingo (Talk | contribs) m (Text replace - "<code cppqt3>" to "<syntaxhighlight lang="cpp-qt">") |
|||
| Line 17: | Line 17: | ||
help. To assign a tooltip to widget, use the | help. To assign a tooltip to widget, use the | ||
{{qt3|QToolTip}} class. | {{qt3|QToolTip}} class. | ||
| − | < | + | <syntaxhighlight lang="cpp-qt"> |
QToolTip::add(w, i18n("This widget does something.")) | QToolTip::add(w, i18n("This widget does something.")) | ||
</code> | </code> | ||
| Line 24: | Line 24: | ||
of the [http://api.kde.org/3.5-api/kdelibs-apidocs/kdeui/html/classKAction.html KAction] constructor: | of the [http://api.kde.org/3.5-api/kdelibs-apidocs/kdeui/html/classKAction.html KAction] constructor: | ||
| − | < | + | <syntaxhighlight lang="cpp-qt"> |
action = new KAction(i18n("&Delete"), "editdelete", | action = new KAction(i18n("&Delete"), "editdelete", | ||
SHIFT+Key_Delete, actionCollection(), "del") | SHIFT+Key_Delete, actionCollection(), "del") | ||
| Line 32: | Line 32: | ||
respective menu item is highlighted: | respective menu item is highlighted: | ||
| − | < | + | <syntaxhighlight lang="cpp-qt"> |
action->setStatusText(i18n("Deletes the marked file")) | action->setStatusText(i18n("Deletes the marked file")) | ||
</code> | </code> | ||
| Line 39: | Line 39: | ||
code: | code: | ||
| − | < | + | <syntaxhighlight lang="cpp-qt"> |
QWhatsThis::add(w, i18n("<qt>This demonstrates <b>Qt</b>'s" | QWhatsThis::add(w, i18n("<qt>This demonstrates <b>Qt</b>'s" | ||
" rich text engine.<ul>" | " rich text engine.<ul>" | ||
| Line 48: | Line 48: | ||
For menu items, use | For menu items, use | ||
| − | < | + | <syntaxhighlight lang="cpp-qt"> |
action->setWhatsThis(i18n("Deletes the marked file")) | action->setWhatsThis(i18n("Deletes the marked file")) | ||
</code> | </code> | ||
| Line 56: | Line 56: | ||
class. In order to show the manual of your application, just use | class. In order to show the manual of your application, just use | ||
| − | < | + | <syntaxhighlight lang="cpp-qt"> |
kapp->invokeHelp() | kapp->invokeHelp() | ||
</code> | </code> | ||
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, use the QToolTip class.
QToolTip::add(w, i18n("This widget does something.")) </code> 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 of the [http://api.kde.org/3.5-api/kdelibs-apidocs/kdeui/html/classKAction.html KAction] constructor: <syntaxhighlight lang="cpp-qt"> action = new KAction(i18n("&Delete"), "editdelete", SHIFT+Key_Delete, actionCollection(), "del") </code> Here it is also possible to assign a text which is shown in the status bar when the respective menu item is highlighted: <syntaxhighlight lang="cpp-qt"> action->setStatusText(i18n("Deletes the marked file")) </code> The API for "What's this?' help is very similar. In dialogs, use the following code: <syntaxhighlight lang="cpp-qt"> QWhatsThis::add(w, i18n("<qt>This demonstrates <b>Qt</b>'s" " rich text engine.<ul>" "<li>Foo</li>" "<li>Bar</li>" "</ul></qt>")) </code> For menu items, use <syntaxhighlight lang="cpp-qt"> action->setWhatsThis(i18n("Deletes the marked file")) </code> The invocation of khelpcenter is encapsulated in the [http://api.kde.org/3.5-api/kdelibs-apidocs/kdecore/html/classKApplication.html KApplication] class. In order to show the manual of your application, just use <syntaxhighlight lang="cpp-qt"> kapp->invokeHelp() </code> 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:'' [mailto:bernd@kdevelop.org Bernd Gehrmann] [[Category:KDE3]] [[Category:Architecture]]