Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How can I scale my WebView content size?
Forum Updated to NodeBB v4.3 + New Features

How can I scale my WebView content size?

Scheduled Pinned Locked Moved QML and Qt Quick
7 Posts 2 Posters 4.6k Views 1 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.
  • T Offline
    T Offline
    troublesohard
    wrote on last edited by
    #1

    Hi. I'm using code like this

    @
    WebView {
    anchors.fill: parent
    }
    @

    Content of my WebView is scaled depend on parent size. Can I set some property to see real size of web content?

    1 Reply Last reply
    0
    • O Offline
      O Offline
      onek24
      wrote on last edited by
      #2

      Hello and welcome to devnet,

      this should be the properties you are searching for:
      "WebView Preferred Height":http://qt-project.org/doc/qt-4.8/qml-webview.html#preferredHeight-prop
      "WebView Preferred Width":http://qt-project.org/doc/qt-4.8/qml-webview.html#preferredWidth-prop

      1 Reply Last reply
      0
      • T Offline
        T Offline
        troublesohard
        wrote on last edited by
        #3

        Sorry, I didn't mention I'm using qt 5.2.
        Looks like, there is no such properties for WebView qt 5.2.

        1 Reply Last reply
        0
        • O Offline
          O Offline
          onek24
          wrote on last edited by
          #4

          I am using Qt 5.2.1 and i found these properties. To set them:
          @WebView {
          preferredHeight: someNumber
          preferredWidth: someNumber
          }@
          To read them:
          @WebView {
          id: myWebKit
          }
          function getWebSize(){
          var width = myWebKit.preferredWidth
          var height = myWebKit.preferredHeight
          }@

          1 Reply Last reply
          0
          • T Offline
            T Offline
            troublesohard
            wrote on last edited by
            #5

            Here my code

            @import QtQuick 2.0
            import QtWebKit 3.0

            WebView {

            id: webView
            
            preferredHeight: 100
            preferredWidth: 100
            

            }@

            I'm receiving error - Cannot assign to non-existent property "preferredWidth" preferredWidth: 100

            Can't find this property in docs "WebView 5.2":http://qt-project.org/doc/qt-5/qml-qtwebkit-webview.html

            [quote author="onek24" date="1394468064"]

            @WebKit {
            preferredHeight: someNumber
            preferredWidth: someNumber
            }@

            [/quote]

            What kind of qml type WebKit? or did you mean WebView?

            1 Reply Last reply
            0
            • O Offline
              O Offline
              onek24
              wrote on last edited by
              #6

              I was found these properties in the Qt 4.8 WebView Documentation, i am sceptical about the 5.x documentation of WebView because it is really thin.
              PreferredWidth and -Height should be a property of one of its classes it iherits from. I'll see what i can find.

              bq. What kind of qml type WebKit? or did you mean WebView?

              Yes i did mean WebView, i corrected my literal.

              1 Reply Last reply
              0
              • T Offline
                T Offline
                troublesohard
                wrote on last edited by
                #7

                I solve my problem using experimental.userAgent property

                @
                import QtWebKit.experimental 1.0

                WebView {

                 anchoranchors.fill: parent
                 experimental.userAgent: "Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25"
                

                }
                @

                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