Qt World Summit: Submit your Presentation

How to make QWebEngineView recognize qthelp URL scheme?

  • Hello everybody,

    I am trying to implement the help browser using QWebEngineView:

    class HelpBrowser : public QWebEngineView
            HelpBrowser(QHelpEngine & help_engine, QWidget* parent);
    	void setUrl(const QUrl &url);
            QHelpEngine & helpEngine;


    void HelpBrowser::setUrl(const QUrl &url)
        setHtml(helpEngine.fileData(url), url);

    Loading the initial page as


    works, but the links are not working. When clicked, the error messages are printed in the Application Output:

    gvfs-open: qthelp://editor_help/help/file_formats.html: error opening location: The specified location is not supported

    Thank you in advance for any suggestions!


  • Moderators

    @roni219 That is because QWebEngineView doesnot understand what qthelp protocol is and thus tries to open it in external handler and thus the error.
    AFAIK assitant is the proper tool to open these files.
    Here is an example to open them at runtime.

    Apart from that if you know the exact locations(local path) of these files QWebEngineView should be able open them.
    For eg. One of the Qt help files on my system:

    Well atleast firefox opens them nicely(with css and stuff intact) using local path and so should QWebEngineView.

  • Thank you for reply, @p3c0 !

    I implemented Help window based on the example. The implementation used QTextBrowser (and so does Assistant). It suits my needs because the help content can be compressed in *.qhc and *.qch files, and deployed with the application. It turned out that QTextBrowser was not the best option for displaying HTML files.

    The dilemma:

    • QTextBrowser recognozes qthelp URL scheme but has limited support for HTML formatting

    • QWebEngineView displays HTML files nicely but does not recognize qthelp URLs

    I found suggestion that QWebEngineView can recognize the qthelp with QWebEngineUrlSchemeHandler, but the post does not explain how to do it.

  • Why do you need qthelp URLs? you can put your html files in a resource (.qrc) and they will be packed with the application. Any particular reason why you'd want *.qhc files?

  • No, i used qthelp only because of the example. In fact resources would be much simpler to deploy.

    • Does QWebEngineView support qrc URL scheme?

    • Will it know that the relative links in a "qrc://" HTML file are links to qrc files?

  • I just tried it, and the answer is "yes" to both questions.

    Thank you everybody for the help with this and the previous topic, especially @VRonin for suggesting QWebEngineView and qrc!

  • Moderators

    @roni219 said in How to make QWebEngineView recognize qthelp URL scheme?:

    for suggesting QWebEngineView and qrc!

    Just be sure to compile your resources externally and load them at runtime, instead of compiling them into the application binary. Here's more info.

    Kind regards.

  • Thank you, @kshegunov, excellent advice! I will compile the resources externally.

Log in to reply