title: QSplitter does not correctly set sizes
body: <p>I have a horizontal QSplitter with two widgets. I want to replace the right hand widget with a new one in a way that the proportions the user has set are maintained. Below is a simplified version of the code I currently have:</p>
  
  <pre><code>MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow)
  {
      ui-&gt;setupUi(this);
  
      splitter = new QSplitter(this);
      splitter-&gt;setOrientation(Qt::Horizontal);
  
      leftWidget = new QPushButton("left", splitter);
      rightWidget = new QPushButton("right", splitter);
  
      splitter-&gt;addWidget(leftWidget);
      splitter-&gt;addWidget(rightWidget);
  
      setCentralWidget(splitter);
  }
  
  void MainWindow::swapLayout()
  {
      QList&lt;int&gt; sizes = splitter-&gt;sizes();
  
      rightWidget-&gt;deleteLater();
      splitter-&gt;update();
  
      rightWidget = new QPushButton("new right", splitter);
  
      splitter-&gt;addWidget(rightWidget);
      splitter-&gt;setSizes(sizes);
  }
  </code></pre>
  
  <p>swapLayout() saves the sizes, removes the right widget, adds a new right hand widget and attempts to reset the sizes. However the left hand widget occupies 100% of the space. Without trying to restore the sizes the widgets both take up 50% of the space.</p>