Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved qt 5.6 WebEngine open local html file

    QtWebEngine
    2
    2
    2424
    Loading More Posts
    • 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.
    • D
      dgsstan last edited by

      Hi,

      I am very new to qt and I am trying to open a local html file.
      I am using qt 5.6 and using the example file from qt example but it shows me how to open html file on the web.

      I tried changing url in main.qml file to the following:
      url: "qrc:/minimal/html/index.html"

      I place my html folder in minimal folder where the main.qml is located.

      When I run the application it says cant find the page.
      I tried looking at other help pages on source forge and this forum and was unable to get it to work as they were for older qt version.

      Can someone please help me out?

      Thank you
      Stan

      1 Reply Last reply Reply Quote 0
      • M
        Matthias1 last edited by

        Using qrc worked for me (Qt 5.8). Are you sure you added the file to the qml.qrc file?

        Should look something like

        qml.qrc

        <RCC>
            <qresource prefix="/">
                ...
                <file>minimal/html/index.html</file>
            </qresource>
        </RCC>
        

        and in the qml

        WebEngineView {
            anchors.fill: parent
            url: "qrc:/minimal/html/index.html"
        }
        

        I believe the url just follows the same scheme as in this S/O answer, so you should also be able to use something like file:///yourpath/minimal/html/index.html

        1 Reply Last reply Reply Quote 1
        • First post
          Last post