[solved][Qt 5.4][QML] ios webview not working as expected



  • Hi

    I got a problem with WebView component. I am trying to load a page but my url is never set. Whenever I check url its alweys empty string.

    My simple code:

    import QtQuick 2.0
    import QtWebView 1.0
    
    Item {
        width: 100
        height: 62
        z: 0
        WebView{
            width: parent.width
            height: parent.height
            url: "qrc:/hotel/html/index.html"
        }
    
    }
    

    my pro file:

    QT +=webview
    

  • Moderators

    @kolegs AFAIK WebView just invokes the web browser that is native to the underlying operating system and thus it may not understand how to load file from Qt's Resource System.



  • WebView element is actually a wrapped native iOS web view. It won't work with a Qt resource file. You should try something like this:
    Your *.pro file:

    ios {
    	BUNDLE_DATA.files = $$$$files($$$$PWD/resources/index.html)    // it should be double dollar signs here!
    	QMAKE_BUNDLE_DATA += BUNDLE_DATA
    }
    

    Your *.qml file:

    WebView {
        width: parent.width
        height: parent.height
        url: "./index.html"
    }
    

    Make sure resources/index.html is present in your source code directory.



  • You may be right but why isn't working with remote pages(tried www.google.pl), and why url string is always empty.


  • Moderators

    @kolegs Perhaps you should try prepending http:// to the url.



  • Dont know why but it works with Qt 5.5RC version without any changes in code


Log in to reply
 

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