qt如何实现点击按钮打开指定文档?
发布网友
发布时间:2022-04-24 02:14
我来回答
共1个回答
热心网友
时间:2023-10-21 08:36
connect(m_HelpAct, SIGNAL(triggered()), this, SLOT(OnHelp()));
实现槽函数:
void CXXX::OnHelp(){
QString runPath = QCoreApplication::applicationDirPath(); //获取exe路劲。
QString helpName = "帮助文档.pdf";
QString helpPath = QString("%1/%2").arg(runPath).arg(helpName);
QFile bfilePath(helpPath);
if(!bfilePath.exists()){
return;
}
QString filePath = "file:///" + helpPath; //打开文件夹用filse:///,打开网页用http://
QDesktopServices::openUrl(QUrl::fromLocalFile(filePath));
}
热心网友
时间:2023-10-21 08:36
connect(m_HelpAct, SIGNAL(triggered()), this, SLOT(OnHelp()));
实现槽函数:
void CXXX::OnHelp(){
QString runPath = QCoreApplication::applicationDirPath(); //获取exe路劲。
QString helpName = "帮助文档.pdf";
QString helpPath = QString("%1/%2").arg(runPath).arg(helpName);
QFile bfilePath(helpPath);
if(!bfilePath.exists()){
return;
}
QString filePath = "file:///" + helpPath; //打开文件夹用filse:///,打开网页用http://
QDesktopServices::openUrl(QUrl::fromLocalFile(filePath));
}
热心网友
时间:2023-10-21 08:36
connect(m_HelpAct, SIGNAL(triggered()), this, SLOT(OnHelp()));
实现槽函数:
void CXXX::OnHelp(){
QString runPath = QCoreApplication::applicationDirPath(); //获取exe路劲。
QString helpName = "帮助文档.pdf";
QString helpPath = QString("%1/%2").arg(runPath).arg(helpName);
QFile bfilePath(helpPath);
if(!bfilePath.exists()){
return;
}
QString filePath = "file:///" + helpPath; //打开文件夹用filse:///,打开网页用http://
QDesktopServices::openUrl(QUrl::fromLocalFile(filePath));
}
热心网友
时间:2023-10-21 08:36
connect(m_HelpAct, SIGNAL(triggered()), this, SLOT(OnHelp()));
实现槽函数:
void CXXX::OnHelp(){
QString runPath = QCoreApplication::applicationDirPath(); //获取exe路劲。
QString helpName = "帮助文档.pdf";
QString helpPath = QString("%1/%2").arg(runPath).arg(helpName);
QFile bfilePath(helpPath);
if(!bfilePath.exists()){
return;
}
QString filePath = "file:///" + helpPath; //打开文件夹用filse:///,打开网页用http://
QDesktopServices::openUrl(QUrl::fromLocalFile(filePath));
}