Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [solved][Qt 5.4][QML] ios webview not working as expected
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Mobile and Embedded
webviewiosqml
6 Posts 3 Posters 2.7k Views
  • 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.
  • K Offline
    K Offline
    kolegs
    wrote on last edited by kolegs
    #1

    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
    
    p3c0P 1 Reply Last reply
    0
    • K kolegs

      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
      
      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

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

      157

      1 Reply Last reply
      0
      • M Offline
        M Offline
        m_andrej
        wrote on last edited by m_andrej
        #3

        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.

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kolegs
          wrote on last edited by
          #4

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

          p3c0P 1 Reply Last reply
          0
          • K kolegs

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

            p3c0P Offline
            p3c0P Offline
            p3c0
            Moderators
            wrote on last edited by
            #5

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

            157

            1 Reply Last reply
            0
            • K Offline
              K Offline
              kolegs
              wrote on last edited by
              #6

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

              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