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
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Mobile and Embedded
webviewiosqml
6 Posts 3 Posters 2.8k Views 2 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.
  • K Offline
    K Offline
    kolegs
    wrote on 25 Jun 2015, 09:59 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
    
    P 1 Reply Last reply 25 Jun 2015, 10:18
    0
    • K kolegs
      25 Jun 2015, 09:59

      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
      
      P Offline
      P Offline
      p3c0
      Moderators
      wrote on 25 Jun 2015, 10:18 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 25 Jun 2015, 10:19 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 25 Jun 2015, 10:33 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.

          P 1 Reply Last reply 25 Jun 2015, 10:52
          0
          • K kolegs
            25 Jun 2015, 10:33

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

            P Offline
            P Offline
            p3c0
            Moderators
            wrote on 25 Jun 2015, 10:52 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 25 Jun 2015, 11:32 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

              2/6

              25 Jun 2015, 10:18

              4 unread
              • Login

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