首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > QT开发 >

初学者救助~用QT打开chm格式的文件

2012-05-07 
菜鸟救助~用QT打开chm格式的文件void MainWindow::on_actionHelp_triggered(){QDesktopServices::openUrl(

菜鸟救助~用QT打开chm格式的文件
void MainWindow::on_actionHelp_triggered()
{
  QDesktopServices::openUrl(QUrl::fromLocalFile("D:\QT\pmc\help.chm"));
}

我想做类似于点击菜单下的“帮助”然后打开一个chm帮助文档,参考了网上别人的文章,可是点击“帮助”后一点反应也没有啊,换成下面这个也一样。

QDesktopServices::openUrl(QUrl("D:\QT\pmc\help.chm"));

[解决办法]
QDesktopServices::openUrl(QUrl("file:///C:/Documents and Settings/All Users/Desktop", QUrl::TolerantMode));
[解决办法]
bool QDesktopServices::openUrl ( const QUrl & url ) [static]
Opens the given url in the appropriate Web browser for the user's desktop environment, and returns true if successful; otherwise returns false.
If the URL is a reference to a local file (i.e., the URL scheme is "file") then it will be opened with a suitable application instead of a Web browser.
The following example opens a file on the Windows file system residing on a path that contains spaces:
 QDesktopServices::openUrl(QUrl("file:///C:/Documents and Settings/All Users/Desktop", QUrl::TolerantMode));
If a mailto URL is specified, the user's e-mail client will be used to open a composer window containing the options specified in the URL, similar to the way mailto links are handled by a Web browser.
For example, the following URL contains a recipient (user@foo.com), a subject (Test), and a message body (Just a test):
 mailto:user@foo.com?subject=Test&body=Just a test
Warning: Although many e-mail clients can send attachments and are Unicode-aware, the user may have configured their client without these features. Also, certain e-mail clients (e.g., Lotus Notes) have problems with long URLs.
See also setUrlHandler().

热点排行