1、如果未点击时提示(即鼠标移到按钮的区域时显示提示信息),则可用setToolTip()函数:
void saveButton();
void stopsaveButton();
...
QPushButton SaveButton;
QPushButton Stop_SaveButton;
...
SaveButton.setToolTip(tr("保存"));
...
Stop_SaveButton.setToolTip(tr("停止"));
2、如果点击按钮后显示提示信息,则可在槽函数中设置QMessageBox类,该类有一个专门显示信息的函数information()函数,当执行了该函数时,会显示一个消息对话框,具体用法如下:
void Widget::about_usMessage()
{
QMessageBox::StandardButton reply;
reply = QMessageBox::information(this, tr("使用说明"), MESSAGE);
}
void Widget::exitMessage()
{
QMessageBox::StandardButton reply;
reply = QMessageBox::information(this, tr("EXIT"),
tr("exit") );
this->close();
}
MESSAGE是一个宏定义,定义了消息对话框写的内容。