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. [SOLVED] How to adjust image size retrieved from XML in WebView in QML?
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] How to adjust image size retrieved from XML in WebView in QML?

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 1 Posters 3.5k 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.
  • H Offline
    H Offline
    honeyhong
    wrote on 8 Aug 2012, 08:31 last edited by
    #1

    Hey. I resized my WebView and to fit the screen, but only the text could fit nicely, not the image.
    After scaling, the text in the image, will scale to small along with the image, which made it hard to read.

    @ Flickable {
    id: flicker1
    width: window.width
    height:parent.height
    anchors{left:parent.left; leftMargin:5; right:parent.right; rightMargin:8}
    flickableDirection:Flickable.VerticalFlick
    contentWidth: web.width
    contentHeight: web.height
    clip: true

                WebView {
                    id:web
                    html:itemNews
                    transformOrigin: WebView.TopLeft
                    preferredWidth: window.width - 10
                    preferredHeight: window.height
                    settings.defaultFontSize : (window.width/480)*25
                }@
    

    The XML that I retrieved the data from contained image that are predetermined with width and height. Which made it hard for me to fit it in the device screen.
    Eg :
    img src="http://www.appsfactory.my/client/canonmsia2/images/uploadfiles/ICP/Products/IXUS240HS-1.jpg" style="width:700px;height:985px;vertical-align:middle"

    Can anyone show me how can I manually adjust the image size.

    1 Reply Last reply
    0
    • H Offline
      H Offline
      honeyhong
      wrote on 14 Aug 2012, 09:23 last edited by
      #2

      Solved it with some hints from my friend.
      Set it like this. The item fit in nicely.
      @WebView {
      id:web
      html: "<html><head><content="width=device-width"/><style>
      img{max-width:100%;max-height:device-height;}
      a:link {color: #0000FF; text-decoration: none;}</style>
      </head><body style="color:black">"+itemNews+"</body></html>";

      transformOrigin: WebView.TopLeft
      preferredWidth:window.width - 10
      settings.defaultFontSize : (window.width/480)*25
                 }@
      
      1 Reply Last reply
      0

      1/2

      8 Aug 2012, 08:31

      • Login

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