title: Qt: Strange behavior when calling setGeometry on a widget in QScrollArea
body: <p>My environment is the following:</p>
  
  <ul>
  <li>Qt 5.4, build from source with <code>-platform win32-msvc2013 -opengl desktop -no-icu -skip webkit</code></li>
  <li>Visual Studio 2013</li>
  <li>Windows 7 x64</li>
  </ul>
  
  <p>Consider the following setup (A QScrollArea containing a centered widget with fixed size):</p>
  
  <pre><code>QScrollArea scrollArea;
  scrollArea.setAlignment(Qt::AlignCenter);
  scrollArea.setWidgetResizable(false);
  QWidget scrollAreaWidgetContents;
  scrollArea.setWidget(scrollAreaWidgetContents);
  </code></pre>
  
  <p>Now, I want to resize that widget within my program like the following:</p>
  
  <pre><code>int w = 200, h = 200;
  scrollAreaWidgetContents.setGeometry(0, 0, w, h);
  </code></pre>
  
  <p><strong>And here comes the strange behavior:</strong><br>
  If <code>w</code> and <code>h</code> are equal to the current width and height (i.e. nothing changes), the widget jumps to the upper left corner.<br>
  If <code>w</code> and <code>h</code> are different from the current width and height, the widgets stays at its centered position and changes its size correctly.</p>
  
  <p>I have written a little demo application that demonstrates the issue. If you click the <code>pushButton_Stay</code> button, the widgets jumps to the upper left corner.</p>
  
  <pre><code>    #include &lt;QtWidgets/QApplication&gt;
      #include &lt;QPushButton&gt;
      #include &lt;QVBoxLayout&gt;
      #include &lt;QScrollArea&gt;
  
      QScrollArea *scrollArea;
      QWidget *scrollAreaWidgetContents;
      QPushButton *pushButton_Up;
      QPushButton *pushButton_Down;
      QPushButton *pushButton_Stay;
      QVBoxLayout *layout;
  
      int w = 200, h = 200;
  
      void sizeUp() {
          w += 10;
          h += 10;
          scrollAreaWidgetContents-&gt;setGeometry(0, 0, w, h);
      }
  
      void sizeDown() {
          w -= 10;
          h -= 10;
          scrollAreaWidgetContents-&gt;setGeometry(0, 0, w, h);
      }
  
      void sizeStay() {
          scrollAreaWidgetContents-&gt;setGeometry(0, 0, w, h);
      }
  
      int main(int argv, char **args)
      {
          QApplication app(argv, args);
  
          // Scroll area
          scrollArea = new QScrollArea;
          scrollArea-&gt;setWidgetResizable(false);
          scrollArea-&gt;setAlignment(Qt::AlignCenter);
          scrollAreaWidgetContents = new QWidget();
          scrollAreaWidgetContents-&gt;setGeometry(QRect(0, 0, w, h));
          scrollAreaWidgetContents-&gt;setAutoFillBackground(true);
          QPalette Pal(scrollAreaWidgetContents-&gt;palette());
          Pal.setColor(QPalette::Background, Qt::black);
          scrollAreaWidgetContents-&gt;setPalette(Pal);
          scrollArea-&gt;setWidget(scrollAreaWidgetContents);
  
          // Buttons
          pushButton_Up = new QPushButton(scrollAreaWidgetContents);
          pushButton_Up-&gt;setGeometry(QRect(85, 50, 31, 23));
          pushButton_Up-&gt;setText("+");
          pushButton_Down = new QPushButton(scrollAreaWidgetContents);
          pushButton_Down-&gt;setGeometry(QRect(85, 110, 31, 23));
          pushButton_Down-&gt;setText("-");
          pushButton_Stay = new QPushButton(scrollAreaWidgetContents);
          pushButton_Stay-&gt;setGeometry(QRect(85, 80, 31, 23));
          pushButton_Stay-&gt;setText("0");
          QObject::connect(pushButton_Up, &amp;QPushButton::clicked, sizeUp);
          QObject::connect(pushButton_Stay, &amp;QPushButton::clicked, sizeStay);
          QObject::connect(pushButton_Down, &amp;QPushButton::clicked, sizeDown);
  
          // Central layout
          layout = new QVBoxLayout;
          layout-&gt;addWidget(scrollArea);
  
          // Main window
          QWidget window;
          window.setGeometry(200, 200, 400, 400);
          window.setLayout(layout);
          window.show();
  
          return app.exec();
      }
  </code></pre>
  
  <p>Clicking the <code>pushButton_Up</code> button:</p>
  
  <p><img src="https://i.stack.imgur.com/5aozz.png" alt="First picture"></p>
  
  <p>Clicking the <code>pushButton_Stay</code> button:</p>
  
  <p><img src="https://i.stack.imgur.com/O8mip.png" alt="Second picture"></p>
  
  <p><strong>Questions:</strong></p>
  
  <p>What's going wrong here?</p>
  
  <p>Is it a bug? An if and yes, can anyone confirm it?</p>
  
  <p>If it's not a bug, how can I make it that the widget always stays centered?</p>