為菜單Help下的About添加響應
about對應actionAbout
點擊QAction會發出triggered()信號,所以,我們要做的是聲明一個slot,然后connect這個信號。
頭文件中
public slots:
void showAboutMsg();
構造函數中
connect(actionAbout,SIGNAL(triggered()),this,SLOT(showAboutMsg()));
實現:
void ExcelReport::showAboutMsg()
{
QMessageBox msgBox(this);
msgBox.setWindowTitle("About");
msgBox.setTextFormat(Qt::RichText); //this is what makes the links clickable
msgBox.setText("QQ:895377235<br>Email:<a href='mailto:hnrayer@gmail.com'>hnrayer@gmail.com</a><br>WebSite:<a href=http://www.cnblogs.com/elesos/ >elesos</a>");
msgBox.setIconPixmap(QPixmap(":/ico/res/ExcelReport.ico"));
msgBox.exec();
}