title: How to update a window in QT?
body: <p>Im working on a simple project in QtCreator where you input text into a line_edit which then gets printed after clicking a button. It works but I need to resize the window in order to see the updated/changed display.</p>
  
  <p>So starting off with the main.cpp, I have left it as default after some tests: </p>
  
  <pre><code>#include "mainwindow.h"
  #include &lt;QApplication&gt;
  
  int main(int argc, char *argv[])
  {
      QApplication a(argc, argv);
      MainWindow w;
      w.show();
      return a.exec();
  }
  </code></pre>
  
  <p>That has the issue I was talking about above. I decided to add <code>w.update();</code> and see if that fixed the issue, it did not. I thought maybe it was because the program was not looping, so I entered the code in a while(true) loop which also was to no avail. </p>
  
  <p>The mainwindow.cpp file is as follows:</p>
  
  <pre><code>#include "mainwindow.h"
  #include "ui_mainwindow.h"
  
  MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow)
  {
      ui-&gt;setupUi(this);
      connect(ui-&gt;textBtn, SIGNAL(clicked(bool)), this, SLOT(setText()));
  }
  
  MainWindow::~MainWindow()
  {
      delete ui;
  }
  
  void MainWindow::setText()
  {
      QString temp = ui-&gt;inputText-&gt;text();
      ui-&gt;displayLabel-&gt;setText(temp);
  
  }
  </code></pre>
  
  <p>MainWindow.hpp:</p>
  
  <pre><code>#ifndef MAINWINDOW_H
  #define MAINWINDOW_H
  
  #include &lt;QMainWindow&gt;
  
  namespace Ui {
  class MainWindow;
  }
  
  class MainWindow : public QMainWindow
  {
      Q_OBJECT
  
  public:
      explicit MainWindow(QWidget *parent = nullptr);
      ~MainWindow();
  
  public slots:
      void setText();
  
  private:
      Ui::MainWindow *ui;
  };
  
  #endif // MAINWINDOW_H
  </code></pre>
  
  <p>Is there a QObject or predifined function in QT that allows me to update the window or automatically updates the window after a detected user change?</p>
  
  <p>Edit: The UI file might be of importance as well:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;ui version="4.0"&gt;
   &lt;class&gt;MainWindow&lt;/class&gt;
   &lt;widget class="QMainWindow" name="MainWindow"&gt;
    &lt;property name="geometry"&gt;
     &lt;rect&gt;
      &lt;x&gt;0&lt;/x&gt;
      &lt;y&gt;0&lt;/y&gt;
      &lt;width&gt;554&lt;/width&gt;
      &lt;height&gt;463&lt;/height&gt;
     &lt;/rect&gt;
    &lt;/property&gt;
    &lt;property name="windowTitle"&gt;
     &lt;string&gt;MainWindow&lt;/string&gt;
    &lt;/property&gt;
    &lt;widget class="QWidget" name="centralWidget"&gt;
     &lt;widget class="QLabel" name="displayLabel"&gt;
      &lt;property name="geometry"&gt;
       &lt;rect&gt;
        &lt;x&gt;140&lt;/x&gt;
        &lt;y&gt;150&lt;/y&gt;
        &lt;width&gt;251&lt;/width&gt;
        &lt;height&gt;91&lt;/height&gt;
       &lt;/rect&gt;
      &lt;/property&gt;
      &lt;property name="text"&gt;
       &lt;string/&gt;
      &lt;/property&gt;
      &lt;property name="scaledContents"&gt;
       &lt;bool&gt;true&lt;/bool&gt;
      &lt;/property&gt;
      &lt;property name="wordWrap"&gt;
       &lt;bool&gt;true&lt;/bool&gt;
      &lt;/property&gt;
     &lt;/widget&gt;
     &lt;widget class="QWidget" name="layoutWidget"&gt;
      &lt;property name="geometry"&gt;
       &lt;rect&gt;
        &lt;x&gt;130&lt;/x&gt;
        &lt;y&gt;30&lt;/y&gt;
        &lt;width&gt;251&lt;/width&gt;
        &lt;height&gt;81&lt;/height&gt;
       &lt;/rect&gt;
      &lt;/property&gt;
      &lt;layout class="QVBoxLayout" name="verticalLayout"&gt;
       &lt;item&gt;
        &lt;widget class="QLineEdit" name="inputText"/&gt;
       &lt;/item&gt;
       &lt;item&gt;
        &lt;widget class="QPushButton" name="textBtn"&gt;
         &lt;property name="text"&gt;
          &lt;string&gt;Display Text&lt;/string&gt;
         &lt;/property&gt;
        &lt;/widget&gt;
       &lt;/item&gt;
      &lt;/layout&gt;
     &lt;/widget&gt;
    &lt;/widget&gt;
    &lt;widget class="QMenuBar" name="menuBar"&gt;
     &lt;property name="geometry"&gt;
      &lt;rect&gt;
       &lt;x&gt;0&lt;/x&gt;
       &lt;y&gt;0&lt;/y&gt;
       &lt;width&gt;554&lt;/width&gt;
       &lt;height&gt;22&lt;/height&gt;
      &lt;/rect&gt;
     &lt;/property&gt;
    &lt;/widget&gt;
    &lt;widget class="QToolBar" name="mainToolBar"&gt;
     &lt;attribute name="toolBarArea"&gt;
      &lt;enum&gt;TopToolBarArea&lt;/enum&gt;
     &lt;/attribute&gt;
     &lt;attribute name="toolBarBreak"&gt;
      &lt;bool&gt;false&lt;/bool&gt;
     &lt;/attribute&gt;
    &lt;/widget&gt;
    &lt;widget class="QStatusBar" name="statusBar"/&gt;
   &lt;/widget&gt;
   &lt;layoutdefault spacing="6" margin="11"/&gt;
   &lt;resources/&gt;
   &lt;connections/&gt;
  &lt;/ui&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/QxIHO.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QxIHO.gif" alt="enter image description here"></a></p>