QWhatsThis(3qt)

πŸ“¦ version 3.3.8b, in fedora 43, fedora 44

✨ NAME ✨

QWhatsThis β€” the class that answers the eternal question "what even is this widget??" like your most helpful bestie. It's the qwhatsthis page from the 3qt manual, and we're gonna get into it πŸ’–


πŸŽ€ SYNOPSIS πŸŽ€

#include <qwhatsthis.h>

Inherits Qt.

πŸ’« Public Members

  • QWhatsThis ( QWidget * widget )
  • virtual ~QWhatsThis ()
  • virtual QString text ( const QPoint & )
  • virtual bool clicked ( const QString & href )

🌟 Static Public Members

  • void setFont ( const QFont & font )
  • void add ( QWidget * widget, const QString & text )
  • void remove ( QWidget * widget )
  • QString textFor ( QWidget * w, const QPoint & pos = QPoint ( ), bool includeParents = FALSE )
  • QToolButton * whatsThisButton ( QWidget * parent )
  • void enterWhatsThisMode ()
  • bool inWhatsThisMode ()
  • void leaveWhatsThisMode ( const QString & text = QString::null, const QPoint & pos = QCursor::pos ( ), QWidget * w = 0 )
  • void display ( const QString & text, const QPoint & pos = QCursor::pos ( ), QWidget * w = 0 )

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so the QWhatsThis class gives you a simple description of any widget β€” literally answering the question "What's this?" like it's nothing.

"What's this?" help is part of an application's online help system, and its whole job is handing users info about functionality, usage, background, etc. β€” in every level of detail, from tiny short tool tips all the way up to full-on text browsing help windows. The range? Immaculate. πŸ’…

QWhatsThis gives you a single window with an explanatory text that pops up whenever the user asks "What's this?". The default way to trigger it: focus the relevant widget and press Shift+F1. The help text shows up immediately, and it dips as soon as the user does literally anything else. Main character entrance, zero lingering.

⚠️ Heads up bestie: if there's an accelerator for Shift+F1, this mechanism will not work. Periodt.

To add "What's this?" text to a widget you simply call QWhatsThis::add() for that widget. For example β€” assigning text to a menu item? Call QMenuData::setWhatsThis(). Want a global accelerator key? Call QAccel::setWhatsThis(). And if you're using actions, use QAction::setWhatsThis().

The text can be either rich text or plain text. If you give it a rich text formatted string, it gets rendered using the default stylesheet β€” which means you can embed images in there πŸ‘€. See QStyleSheet::defaultSheet() for the details.

const char * fileOpenText = "<p><img source=\"fileopen\"> "
                 "Click this button to open a <em>new file</em>. <br>"
                 "You can also select the <b>Open</b> command "
                 "from the <b>File</b> menu.</p>";
QMimeSourceFactory::defaultFactory()->setPixmap( "fileopen",
                      fileOpenAction->iconSet().pixmap() );
fileOpenAction->setWhatsThis( fileOpenText );

Another way to enter "What's this?" mode is the ready-made tool bar tool button from QWhatsThis::whatsThisButton(). By invoking this context help button (in the picture below, it's the first one from the right), 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.

πŸ–ΌοΈ [Image Omitted] β€” yeah there was a picture right here in the original and it did not survive the journey, rip.

If you're using QMainWindow you can also use the QMainWindow::whatsThis() slot to invoke the mode from a menu item. Slay.

For more control, you can create a dedicated QWhatsThis object for a special widget. By subclassing and reimplementing QWhatsThis::text() it's possible to have different help texts depending on the position of the mouse click. And by reimplementing QWhatsThis::clicked() it's possible to have hyperlinks inside the help texts. Iconic behavior fr.

If you wish to control the "What's this?" behavior of a widget manually, see QWidget::customWhatsThis().

The What's This object can be removed using QWhatsThis::remove(), although this is rarely necessary because it gets automatically removed when the widget is destroyed. Self-cleaning king πŸ‘‘

See also QToolTip and Help System.


πŸ’– MEMBER FUNCTION DOCUMENTATION πŸ’–

QWhatsThis::QWhatsThis ( QWidget * widget )

Constructs a dynamic "What's this?" object for widget. The object is deleted when the widget is destroyed. Gone when its widget's gone, no cap.

When the widget is queried by the user, the text() function of this QWhatsThis will be called to provide the appropriate text β€” rather than using the text assigned by add().

QWhatsThis::~QWhatsThis () [virtual]

Destroys the object and frees any allocated resources. Bye bestie 🫢

void QWhatsThis::add ( QWidget * widget, const QString & text ) [static]

Adds text as "What's this" help for widget. If the text is rich text formatted (i.e. it contains markup) it will be rendered with the default stylesheet QStyleSheet::defaultSheet().

The text is destroyed if the widget is later destroyed, so it need not be explicitly removed.

See also remove().

Examples:

🌸 (the original page lists "Examples:" right here and then… nothing. Just vibes and a blank space. Not me side-eyeing the doc generator πŸ™ˆ)

bool QWhatsThis::clicked ( const QString & href ) [virtual]

This virtual function is called when the user clicks inside the "What's this?" window. href is the link the user clicked on, or QString::null if there was no link.

If the function returns TRUE (the default), the "What's this?" window is closed; otherwise it remains visible.

The default implementation ignores href and returns TRUE.

void QWhatsThis::display ( const QString & text, const QPoint & pos = QCursor::pos ( ), QWidget * w = 0 ) [static]

Display text in a help window at the global screen position pos.

If widget w is not 0 and has its own dedicated QWhatsThis object, this object will receive clicked() messages when the user clicks on hyperlinks inside the help text.

See also QWhatsThis::clicked().

void QWhatsThis::enterWhatsThisMode () [static]

Enters "What's this?" mode and returns immediately β€” no waiting around, we're out. πŸƒβ€β™€οΈ

Qt will install a special cursor and take over mouse input until the user clicks somewhere. It then shows any help available and ends "What's this?" mode. Finally, Qt removes the special cursor and help window and then restores ordinary event processing β€” at which point the left mouse button is no longer pressed.

The user can also use the Esc key to leave "What's this?" mode.

See also inWhatsThisMode() and leaveWhatsThisMode().

bool QWhatsThis::inWhatsThisMode () [static]

Returns TRUE if the application is in "What's this?" mode; otherwise returns FALSE.

See also enterWhatsThisMode() and leaveWhatsThisMode().

void QWhatsThis::leaveWhatsThisMode ( const QString & text = QString::null, const QPoint & pos = QCursor::pos ( ), QWidget * w = 0 ) [static]

Leaves "What's this?" question mode.

This function is used internally by widgets that support QWidget::customWhatsThis(); applications do not usually call it. An example of such a widget is QPopupMenu: menus still work normally in "What's this?" mode but also provide help texts for individual menu items.

If text is not QString::null, a "What's this?" help window is displayed at the global screen position pos. If widget w is not 0 and has its own dedicated QWhatsThis object, this object will receive clicked() messages when the user clicks on hyperlinks inside the help text.

See also inWhatsThisMode(), enterWhatsThisMode(), and QWhatsThis::clicked().

void QWhatsThis::remove ( QWidget * widget ) [static]

Removes the "What's this?" help associated with the widget. This happens automatically if the widget is destroyed.

See also add().

void QWhatsThis::setFont ( const QFont & font ) [static]

Sets the font for all "What's this?" helps to font. Every single one. Glow-up for the whole help system ✨

QString QWhatsThis::text ( const QPoint & ) [virtual]

This virtual function returns the text for position p in the widget that this "What's this?" object documents. If there is no "What's this?" text for the position, QString::null is returned.

The default implementation returns QString::null.

QString QWhatsThis::textFor ( QWidget * w, const QPoint & pos = QPoint ( ), bool includeParents = FALSE ) [static]

Returns the what's this text for widget w, or QString::null if there is no "What's this?" help for the widget. pos contains the mouse position; this is useful, for example, if you've subclassed to make the text that is displayed position dependent.

If includeParents is TRUE, parent widgets are taken into consideration as well when looking for what's this help text. Family reunion time πŸ’œ

See also add().

QToolButton * QWhatsThis::whatsThisButton ( QWidget * parent ) [static]

Creates a QToolButton preconfigured to enter "What's this?" mode when clicked. You will often use this with a tool bar as parent:

(void) QWhatsThis::whatsThisButton( my_help_tool_bar );

Example: helpsystem/mainwindow.cpp.


🌈 SEE ALSO 🌈


Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.


πŸŽ€ AUTHOR πŸŽ€

Generated automatically from the source code. (Not a human, just a little script doing its thing πŸ’…)


πŸ’€ BUGS πŸ’€

If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. 🫢

The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech.

If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qwhatsthis.3qt) and the Qt version (3.3.8).


and that's the whole page bestie!! brought to you by Trolltech AS, dated 2 February 2007, under the title QWhatsThis(3qt) β€” she's vintage, she's iconic, she's still answering "what's this?" like it's her job, because it literally is πŸ’–βœ¨

πŸ“¦ where this page comes from