#include <q3whatsthis.h>
Inheritance diagram for Q3WhatsThis:


Definition at line 37 of file q3whatsthis.h.
Public Member Functions | |
| Q3WhatsThis (QWidget *) | |
| ~Q3WhatsThis () | |
| bool | eventFilter (QObject *, QEvent *) |
| virtual QString | text (const QPoint &) |
| virtual bool | clicked (const QString &href) |
Static Public Member Functions | |
| static void | enterWhatsThisMode () |
| static bool | inWhatsThisMode () |
| static void | add (QWidget *w, const QString &s) |
| static void | remove (QWidget *w) |
| static QToolButton * | whatsThisButton (QWidget *parent) |
| static void | leaveWhatsThisMode (const QString &text=QString(), const QPoint &pos=QCursor::pos(), QWidget *w=0) |
| static void | display (const QString &text, const QPoint &pos=QCursor::pos(), QWidget *w=0) |
| Q3WhatsThis::Q3WhatsThis | ( | QWidget * | widget | ) |
Constructs a new "What's This?" object for widget.
Definition at line 36 of file q3whatsthis.cpp.
References QObject::installEventFilter(), and QLayoutItem::widget().
00037 : QObject(widget) 00038 { 00039 if (widget) 00040 widget->installEventFilter(this); 00041 }
Here is the call graph for this function:

| Q3WhatsThis::~Q3WhatsThis | ( | ) |
Filters events if this object has been installed as an event filter for the watched object.
In your reimplementation of this function, if you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false.
Example:
class MainWindow : public QMainWindow { public: MainWindow(); protected: bool eventFilter(QObject *obj, QEvent *ev); private: QTextEdit *textEdit; }; MainWindow::MainWindow() { textEdit = new QTextEdit; setCentralWidget(textEdit); textEdit->installEventFilter(this); } bool MainWindow::eventFilter(QObject *obj, QEvent *event) { if (obj == textEdit) { if (event->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event); qDebug() << "Ate key press" << keyEvent->key(); return true; } else { return false; } } else { // pass the event on to the parent class return QMainWindow::eventFilter(obj, event); } }
Notice in the example above that unhandled events are passed to the base class's eventFilter() function, since the base class might have reimplemented eventFilter() for its own internal purposes.
Reimplemented from QObject.
Definition at line 55 of file q3whatsthis.cpp.
References clicked(), QWhatsThis::hideText(), o, QObject::parent(), QEvent::QueryWhatsThis, s, QWhatsThis::showText(), text(), QEvent::type(), QEvent::WhatsThis, and QEvent::WhatsThisClicked.
00056 { 00057 if (o != parent() || !o->isWidgetType()) 00058 return false; 00059 00060 if (e->type() == QEvent::WhatsThis) { 00061 QString s = text(static_cast<QHelpEvent*>(e)->pos()); 00062 if (!s.isEmpty()) 00063 QWhatsThis::showText(static_cast<QHelpEvent*>(e)->globalPos(), s, static_cast<QWidget*>(o)); 00064 } else if (e->type() == QEvent::QueryWhatsThis) { 00065 QString s = text(static_cast<QHelpEvent*>(e)->pos()); 00066 if (s.isEmpty()) 00067 return false; 00068 } else if (e->type() == QEvent::WhatsThisClicked) { 00069 QString href = static_cast<QWhatsThisClickedEvent*>(e)->href(); 00070 if (clicked(href)) 00071 QWhatsThis::hideText(); 00072 } else { 00073 return false; 00074 } 00075 return true; 00076 }
Here is the call graph for this function:

| void Q3WhatsThis::enterWhatsThisMode | ( | ) | [inline, static] |
Enters "What's This?" mode and returns immediately.
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.
Definition at line 45 of file q3whatsthis.h.
References QWhatsThis::enterWhatsThisMode().
00045 { QWhatsThis::enterWhatsThisMode(); }
Here is the call graph for this function:

| bool Q3WhatsThis::inWhatsThisMode | ( | ) | [inline, static] |
Returns true if the application is in "What's This?" mode; otherwise returns false.
Definition at line 46 of file q3whatsthis.h.
References QWhatsThis::inWhatsThisMode().
00046 { return QWhatsThis::inWhatsThisMode(); }
Here is the call graph for this function:

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.
Definition at line 48 of file q3whatsthis.h.
| void Q3WhatsThis::remove | ( | QWidget * | widget | ) | [inline, static] |
| QToolButton * Q3WhatsThis::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 );
Definition at line 194 of file q3whatsthis.cpp.
References QObject::parent().
00195 { 00196 return QWhatsThis::whatsThisButton(parent); 00197 }
Here is the call graph for this function:

| void Q3WhatsThis::leaveWhatsThisMode | ( | const QString & | text = QString(), |
|
| const QPoint & | pos = QCursor::pos(), |
|||
| QWidget * | widget = 0 | |||
| ) | [inline, static] |
This function is used internally by widgets that support QWidget::customWhatsThis(); applications do not usually call it. An example of such a widget is Q3PopupMenu: menus still work normally in "What's This?" mode but also provide help texts for individual menu items.
If text is not empty, a "What's This?" help window is displayed at the global screen position pos. If widget widget 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.
Definition at line 51 of file q3whatsthis.h.
References QWhatsThis::showText(), and w.
00052 { QWhatsThis::showText(pos, text, w); }
Here is the call graph for this function:

| void Q3WhatsThis::display | ( | const QString & | text, | |
| const QPoint & | pos = QCursor::pos(), |
|||
| QWidget * | widget = 0 | |||
| ) | [inline, static] |
Display text in a help window at the global screen position pos.
If widget widget 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.
Definition at line 53 of file q3whatsthis.h.
References QWhatsThis::showText(), and w.
00054 { QWhatsThis::showText(pos, text, w); }
Here is the call graph for this function:

This virtual function returns the text for position pos in the widget that this "What's This?" object documents. If there is no "What's This?" text for the position, an empty string is returned.
The default implementation returns an empty string.
Definition at line 85 of file q3whatsthis.cpp.
References QObject::isWidgetType(), and QObject::parent().
Referenced by eventFilter().
00086 { 00087 if (parent() && parent()->isWidgetType()) 00088 return static_cast<QWidget*>(parent())->whatsThis(); 00089 return QString(); 00090 }
Here is the call graph for this function:

| bool Q3WhatsThis::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 an empty string 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.
Definition at line 102 of file q3whatsthis.cpp.
Referenced by eventFilter().
1.5.1