Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QWhatsThis Class

TheQWhatsThis class provides a simple description of any widget, i.e. answering the question "What's This?".More...

Header:#include <QWhatsThis>

Static Public Members

QAction *createAction(QObject * parent = 0)
voidenterWhatsThisMode()
voidhideText()
boolinWhatsThisMode()
voidleaveWhatsThisMode()
voidshowText(const QPoint & pos, const QString & text, QWidget * w = 0)

Detailed Description

TheQWhatsThis class provides a simple description of any widget, i.e. answering the question "What's This?".

"What's This?" help is part of an application's online help system, and provides users with information about the functionality and usage of a particular widget. "What's This?" help texts are typically longer and more detailed thantooltips, but generally provide less information than that supplied by separate help windows.

QWhatsThis provides a single window with an explanatory text that pops up when the user asks "What's This?". The default way for users to ask the question is to move the focus to the relevant widget and press Shift+F1. The help text appears immediately; it goes away as soon as the user does something else. (Note that if there is a shortcut for Shift+F1, this mechanism will not work.) Some dialogs provide a "?" button that users can click to enter "What's This?" mode; they then click the relevant widget to pop up the "What's This?" window. It is also possible to provide a a menu option or toolbar button to switch into "What's This?" mode.

To add "What's This?" text to a widget or an action, you simply callQWidget::setWhatsThis() orQAction::setWhatsThis().

The text can be either rich text or plain text. If you specify a rich text formatted string, it will be rendered using the default stylesheet, making it possible to embed images in the displayed text. To be as fast as possible, the default stylesheet uses a simple method to determine whether the text can be rendered as plain text. See Qt::mightBeRichText() for details.

    newAct=newQAction(tr("&New"),this);    newAct->setShortcut(tr("Ctrl+N"));    newAct->setStatusTip(tr("Create a new file"));    newAct->setWhatsThis(tr("Click this option to create a new file."));

An alternative way to enter "What's This?" mode is to callcreateAction(), and add the returnedQAction to either a menu or a tool bar. By invoking this context help action (in the picture below, the button with the arrow and question mark icon) the user switches into "What's This?" mode. If they now click on a widget the appropriate help text is shown. The mode is left when help is given or when the user presses Esc.

You can enter "What's This?" mode programmatically withenterWhatsThisMode(), check the mode withinWhatsThisMode(), and return to normal mode withleaveWhatsThisMode().

If you want to control the "What's This?" behavior of a widget manually seeQt::WA_CustomWhatsThis.

It is also possible to show different help texts for different regions of a widget, by using aQHelpEvent of typeQEvent::WhatsThis. Intercept the help event in your widget'sQWidget::event() function and callQWhatsThis::showText() with the text you want to display for the position specified inQHelpEvent::pos(). If the text is rich text and the user clicks on a link, the widget also receives aQWhatsThisClickedEvent with the link's reference asQWhatsThisClickedEvent::href(). If aQWhatsThisClickedEvent is handled (i.e.QWidget::event() returns true), the help window remains visible. CallQWhatsThis::hideText() to hide it explicitly.

See alsoQToolTip.

Member Function Documentation

[static]QAction * QWhatsThis::createAction(QObject * parent = 0)

Returns a ready-madeQAction, used to invoke "What's This?" context help, with the givenparent.

The returnedQAction provides a convenient way to let users enter "What's This?" mode.

[static]void QWhatsThis::enterWhatsThisMode()

This function switches the user interface into "What's This?" mode. The user interface can be switched back into normal mode by the user (e.g. by them clicking or pressing Esc), or programmatically by callingleaveWhatsThisMode().

When entering "What's This?" mode, aQEvent of type Qt::EnterWhatsThisMode is sent to all toplevel widgets.

See alsoinWhatsThisMode() andleaveWhatsThisMode().

[static]void QWhatsThis::hideText()

If a "What's This?" window is showing, this destroys it.

See alsoshowText().

[static]bool QWhatsThis::inWhatsThisMode()

Returns true if the user interface is in "What's This?" mode; otherwise returns false.

See alsoenterWhatsThisMode().

[static]void QWhatsThis::leaveWhatsThisMode()

If the user interface is in "What's This?" mode, this function switches back to normal mode; otherwise it does nothing.

When leaving "What's This?" mode, aQEvent of type Qt::LeaveWhatsThisMode is sent to all toplevel widgets.

See alsoenterWhatsThisMode() andinWhatsThisMode().

[static]void QWhatsThis::showText(constQPoint & pos, constQString & text,QWidget * w = 0)

Showstext as a "What's This?" window, at global positionpos. The optional widget argument,w, is used to determine the appropriate screen on multi-head systems.

See alsohideText().

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp