How can I scale my WebView content size?
-
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?
-
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 -
Sorry, I didn't mention I'm using qt 5.2.
Looks like, there is no such properties for WebView qt 5.2. -
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
}@ -
Here my code
@import QtQuick 2.0
import QtWebKit 3.0WebView {
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?
-
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.
-
I solve my problem using experimental.userAgent property
@
import QtWebKit.experimental 1.0WebView {
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"
}
@