Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to make QWebEngineView recognize qthelp URL scheme?
Forum Updated to NodeBB v4.3 + New Features

How to make QWebEngineView recognize qthelp URL scheme?

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 4 Posters 2.7k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    roni219
    wrote on last edited by roni219
    #1

    Hello everybody,

    I am trying to implement the help browser using QWebEngineView:

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

    where

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

    Loading the initial page as

    browser->setUrl(QUrl("qthelp://editor_help/help/index.html"));
    

    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!

    Roni.

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @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.
      http://doc.qt.io/qt-5/qtassistant-remotecontrol-example.html

      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:
      file:///opt/Qt5.7.0/Docs/Qt-5.7/qtcore/qobject.html

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

      157

      1 Reply Last reply
      0
      • R Offline
        R Offline
        roni219
        wrote on last edited by roni219
        #3

        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.

        1 Reply Last reply
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by VRonin
          #4

          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?

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          R 1 Reply Last reply
          0
          • VRoninV VRonin

            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?

            R Offline
            R Offline
            roni219
            wrote on last edited by
            #5

            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?

            1 Reply Last reply
            0
            • R Offline
              R Offline
              roni219
              wrote on last edited by
              #6

              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!

              kshegunovK 1 Reply Last reply
              0
              • R roni219

                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!

                kshegunovK Offline
                kshegunovK Offline
                kshegunov
                Moderators
                wrote on last edited by
                #7

                @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.

                Read and abide by the Qt Code of Conduct

                R 1 Reply Last reply
                0
                • kshegunovK kshegunov

                  @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.

                  R Offline
                  R Offline
                  roni219
                  wrote on last edited by
                  #8

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

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved