QStatusTipEvent Class
QStatusTipEvent 类提供了一个用于在状态栏中显示消息的事件。更多
Header: | #include <QStatusTipEvent> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Gui) target_link_libraries(mytarget PRIVATE Qt6::Gui) |
qmake: | QT += gui |
继承: | QEvent |
- 所有成员的列表,包括继承成员
- QStatusTipEvent 属于事件类和帮助系统。
公共函数
QStatusTipEvent(const QString &tip) | |
QString | tip() const |
详细说明
状态提示可通过QWidget::setStatusTip() 函数设置。当鼠标光标进入 widget 时,状态栏中会显示这些提示。例如
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { QWidget *myWidget = new QWidget; myWidget->setStatusTip(tr("This is my widget.")); setCentralWidget(myWidget); ... } |
还可以使用QAction::setStatusTip() 函数为操作设置状态提示:
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { QMenu *fileMenu = menuBar()->addMenu(tr("File")); QAction *newAct = new QAction(tr("&New"), this); newAct->setStatusTip(tr("Create a new file.")); fileMenu->addAction(newAct); ... } |
最后,通过Qt::StatusTipRole 枚举值,项目视图类也支持状态提示。
另请参阅 QStatusBar,QHelpEvent, 和QWhatsThisClickedEvent 。
成员函数文档
[explicit]
QStatusTipEvent::QStatusTipEvent(const QString &tip)
用tip 指定的文本构造状态提示事件。
另请参阅 tip().
QString QStatusTipEvent::tip() const
返回要在状态栏中显示的信息。
另请参阅 QStatusBar::showMessage()。
© 2025 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 the GNU 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.