title: How can I create a properly sizing QWebView?
body: <p>I want to make a QWebView appear expanding to the width and height so that ideally it will have no scroll bars. Some websites may have fixed widths that wont allow this, but I am not concerned with those. In any case, I cannot do as I wish because QWebView implements sizeHint as follows:</p>
  
  <pre><code>QSize QWebView::sizeHint() const
  {
      return QSize(800, 600); // ####...
  }
  </code></pre>
  
  <p>This is incorrect on a number of levels. 1. It doesnt at all take into account the size of the actual web page. 2. It doesnt take into account that the height and width are related to each other. (To prove #2 think about text in web pages that wraps to the next line.) </p>
  
  <p>As a simple fix I tried to do (where QResizingWebView extends QWebView):</p>
  
  <pre><code>QSize QResizingWebView::sizeHint() const{
      return this->page()->mainFrame()->contentsSize();
  }
  </code></pre>
  
  <p>While this is closer to the result, it also has 2 flaws. 1. It doesnt take into account the relation between the displayed width/height. 2. <code>this-&gt;page()-&gt;mainFrame()-&gt;contentsSize()</code> is inaccurate from what I can tell from my preliminary testing (it has returned heights larger than it should under many cases, although this may be related to #1). </p>
  
  <p>Does anyone have any tips to fix this?</p>