[SOLVED]How to stretch/shrink HTML Page to fit in QWebView window
-
I am using QWebView to render a html page using setHTML method. In the html page body section I am mentioning width and height for the html page, if we are changing the width and hegiht of the QWebView window at run time by calling setGeometry(x,y,w,h), then how to make the html page adjust itself to fit the content fully in streched QWebView window?
-
You could set the width and height in the HTML bodys style dynamically (i.e. manipulate the HTML and then reload page), but this is not very clever. First of all I think you need to define the width and height in percent and not in absolute values (e.g. width: 80% height: 90%). Also you could check for screen resolution - test if widescreen or 4:3 - and set width and height accordingly. Another solution would be to have different style sheets (CSS) for different scenarios and set the appropriate style sheet for your HTML. But beware styles set in the HTML content overrule styles defined by CSS style sheets.
-
Hi Thanks for your suggestion Below mention is the sample code for one html file.
<html><body topmargin="0" leftmargin="0"><embed type="application/x-shockwave-flash" src="http://educomp.com/flash/logos_950.swf" width="950" height="50" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></body></html>
@My HTML page is having a flash content embeded in that , that content should also expand/shrink.
Would you please throw some more light how it can be deal with css.
Please give some examples if you have any. Or any idea can it be done using some javascript.?? -
Sry I'm not that familiar with HTML5 content. From what I found out looking "here":http://www.w3schools.com/html5/tag_embed.asp the embed elements width and height attributes only accept absolute values, so the precent idea won't work. I googled for "dynamically resize embed" and found "this":http://stackoverflow.com/questions/2160363/dynamically-resizing-an-embeded-video-with-jquery, maybe its a solution to your problem.
This links are always helpfull for "HTML":http://www.w3schools.com/html/default.asp and "CSS":http://www.w3schools.com/cssref/default.asp.
-
Hey thanks a lot for your suggestion. Actually the link refereed by you has gave me some thought.
Answer to this problem is dam simpler , I just created mt html doc by passing width as 100% and Height as 100%. Thats all
Rest of the things it automatically takes care, now if I expand or shrink my WebView window, content are also getting adjusted. -
Perfect. Its always a nice feeling to find a simple and elegant solution. ^^