QHelpEvent Class
The QHelpEvent class asks a widget for the help it has at a position, such as a tool tip. More…
| Header | #include <QtGui/qevent.h> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Gui) |
| Module | Nt GUI C++ Classes |
| Inherits | QEvent |
List of all members, including inherited members
Public Functions
| QHelpEvent(Type type, const QPoint &pos, const QPoint &globalPos) | |
| int | x() const |
| int | y() const |
| int | globalX() const |
| int | globalY() const |
| QPoint | pos() const |
| QPoint | globalPos() const |
Reimplemented Public Functions
| QHelpEvent * | clone() const |
Detailed Description
A window sends a QHelpEvent of the type QEvent::ToolTip to the widget under the mouse when the mouse has rested there for a moment. A widget that has something to show for the position shows it and accepts the event; one that does not ignores it, and the event goes on to its parent. Reimplement QWidget::event() to show a tool tip that depends on the position, as a table does for its cells:
bool MyWidget::event(QEvent *event)
{
if (event->type() == QEvent::ToolTip) {
auto *help = static_cast<QHelpEvent *>(event);
QToolTip::showText(help->globalPos(), describe(help->pos()), this);
return true;
}
return QWidget::event(event);
}
See also QEvent and QMouseEvent.
Differences from Qt
There is no WhatsThis event type, and the position is a QPoint.
Member Function Documentation
QHelpEvent::QHelpEvent(Type type, const QPoint &pos, const QPoint &globalPos)
Constructs a help event of the given type for a mouse at pos in the widget and globalPos on the screen.
QHelpEvent * QHelpEvent::clone() const
Reimplements QEvent::clone().
QPoint QHelpEvent::globalPos() const
Returns the position on the screen.
int QHelpEvent::globalX() const
Returns the x coordinate of the position on the screen.
int QHelpEvent::globalY() const
Returns the y coordinate of the position on the screen.
QPoint QHelpEvent::pos() const
Returns the position in the widget.
int QHelpEvent::x() const
Returns the x coordinate of the position in the widget.
int QHelpEvent::y() const
Returns the y coordinate of the position in the widget.