使用setWhatIsThis在Qt与QPushButton
Using setWhatIsThis in Qt with QPushButton
我需要显示一个"帮助文本"当鼠标在一个按钮,我谷歌和我尝试了一些代码,但徒劳的。
谁能给我纠正一下吗?if (event->type() == QEvent::Enter)
{
if (obj == q1)
{
iarm->printStatus("hi"); // For debugging
QAction *newAct = new QAction(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."));
}
}
而不是通过QAction,只是使用你的QPushButton的(好吧,QWidget的真正)setToolTip(const QString &)
。
这将为您的按钮/小部件设置一个工具提示,当鼠标悬停在它上面时出现。这似乎是你想要的,而不是你现在想用的"这是什么"的信息。
你可以使用QpushButton的属性setToolTip (const QString &)同样的原因。这将显示你的帮助文本鼠标悬停在Qpushbutton。
对于智能文本,根据您的要求,您可以为工具提示设置样式表:-
QToolTip {color: #fff;background - color: # 000;边界:没有;}
相关文章:
- QT QPushButton Press Event
- qt如何连接QPushButton的2D数组并返回位置
- 获取QT中所有Qpushbutton的列表
- Qt 错误:错误:调用"QHBoxLayout::addItem(QPushButton*&)"没有匹配函数
- 将属性添加到QT C 中的Qpushbutton
- 如何在 qt 中对 QPushButton 的背景颜色进行动画处理
- Qt 5将带有参数的插槽分配给QPushButton
- Qt C++,点击 QPushButton 时动态执行的操作
- QPushButton的Qt背景图像
- Qt - 如何使 QPushButton 在两个 QVBoxLayout 之间切换
- Qt Symbian C++中 QPushButton 的 Elide 文本
- Qt自定义QPushButton点击信号
- 在QT中捕捉"Tap and hold" QPushButton上的触摸事件时出现问题
- 在按下QPushButton-Qt时将文本从QTextEdit发送到QListWidget
- (Qt C++) QPushButton setIcon() not working
- 在QTableWidget中添加一个QPushButton到qtablewidgetiitem,如何使它Qt::Alig
- 使用setWhatIsThis在Qt与QPushButton
- Qt设置背景颜色的QPushButton
- QHBoxLayout中QPushButton周围的Qt空间
- Qt QSpinbox and QPushButton to Arduino