views:

506

answers:

2

I'm writing an ebook viewer in C++ using Qt 4.5, using the QWebView object to render html files.

Some of the html files need a high window width, otherwise an horizontal scroll bar will appear, which is very annoying, thus I would like to implement an option to fit the content to the window width.

Please, do you have any idea how to make it possible using Qt ?

This is not about hiding the horizontal scrollbar, but about a "fit-to-width" feature.

A: 

This sounds like a problem with the layout of the web page itself.

Check widths in the CSS, and the width of page elements such as images.

For this, I'd strongly recommend viewing the page in Firefox, using the Firebug add-on to inspect elements.

Sam Dutton
this is not about the html file, the program should be able to handle any valid random html file.
karatchov
As far as I know, there would be no way for QWebView to force a layout to fit in its width. For example, if the view width is currently 1000px, what should happen if the page displayed includes a banner image 1200px wide? In other words, the layout of a page depends on its HTML and CSS -- and that can't be 'rewritten' by the QWebView.You could use QWebFrame::setScrollBarPolicy() to get rid of horizontal scrollbars, but that will mean some content could be hidden. Alternatively, you could get the HTML and tweak that before calling QWebView::setHtml().
Sam Dutton
A: 

Maybe you can look up the source code that detects when the page overflows width-wise to create the horizontal scroll bar and get some ideas from there?

cheez