0

我正在尝试学习如何使用 Qt Assistant 在应用程序中显示自定义帮助。

我在 Qt 网站上找到了一个例子:

http://qt-project.org/doc/qt-4.7/help-simpletextviewer.html

(使用 Qt 4.7.3)

所需的所有源文件都在上面的站点上。我创建了 html 和 png 文件并将它们放在项目文件夹内的“帮助”文件夹中。

从命令行运行 Qt Assistant 效果很好。

在助手中加载帮助文件也可以。我不能做的是在帮助文件中加载起始页,如本节所述:http: //qt-project.org/doc/qt-4.7/assistant-custom-help-viewer.html #id-0c628592-dd04-4465-94b1-e5d4a91d7cd4

void Assistant::showDocumentation(const QString &page)
 {
    if (!startAssistant())
        return;

    QByteArray ba("SetSource ");
    ba.append("qthelp://com.trolltech.examples.simpletextviewer/doc/");

    proc->write(ba + page.toLocal8Bit() + '\n');
}

随着SetSource的详细解释显示

    setSource <Url> Displays the given <Url>. The URL can be absolute or relative 
to the currently displayed page. If the URL is absolute, it has to be 
a valid Qt help system URL; i.e., starting with "qthelp://".

我没有网页...但我尝试从本地文件集中显示索引,但我总是收到 404 错误提示“无法加载页面 blahblah/help/index.html”

我怎样才能像他们说的那样创建一个本地路径,或者我怎样才能创建一个“有效的 Qt 帮助系统 URL”?

注意: SetSource 和 setSource 具有完全相同的结果...并且文档和他们自己的示例都使用它们...这些选项不区分大小写吗?

我用一个似乎不正确的解决方案回答了我自己的问题......我将不胜感激。

4

1 回答 1

0

我的解决方案或文档一定有问题......

我能够通过更改选项来显示页面...

代替QByteArray ba("SetSource ");

QByteArray ba("Set Source ");

于 2014-08-11T13:57:44.643 回答