qt 5.6 WebEngine open local html file



  • 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



  • 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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.