title: Qt Command Log using QListWidget
body: <p>I am trying to build a command log on a user interface. Meaning, when the user click a button, check a box, upload some images etc, basically every time the user interacts with the user interface the action is recorded inside a <code>QListWidget</code> Command Log shown below. Basically this is how the ui looks as soon as the user run it:</p>
  
  <p><img src="https://i.imgur.com/JLVZp57.png" alt="start"></p>
  
  <p>And this is what I am try to achieve everytime the user interacts with the ui:</p>
  
  <p><img src="https://i.imgur.com/UPNdMmE.png" alt="command_log"></p>
  
  <p>Below snippets of code from the constructor:</p>
  
  <p><strong>mainwindow.h</strong></p>
  
  <pre><code>private:
      QListWidget *mNewTextSQLLog;
  </code></pre>
  
  <p><strong>mainwindow.cpp</strong></p>
  
  <pre><code>MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow)
  {
      ui-&gt;setupUi(this);
      mDockWidget_A = new QDockWidget(QLatin1String("Command Log"));
      mDockWidget_A-&gt;setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
      mDockWidget_A-&gt;setMinimumHeight(30);
      // Adding object to the DockWidget
      mNewText = new QListWidget;
      mNewText-&gt;setStyleSheet("background-color: light grey;");
      mNewText-&gt;setMinimumHeight(50);
      mNewText-&gt;setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
      mDockWidget_A-&gt;setWidget(mNewText);
      addDockWidget(Qt::BottomDockWidgetArea, mDockWidget_A);
      resizeDocks({mDockWidget_A}, {200}, Qt::Horizontal);
  }
  </code></pre>
  
  <p>And then some command of the ui, for example here is when the user upload images using a <code>QPushButton</code> and images are also shown on a <code>QLabel</code>:</p>
  
  <pre><code>void MainWindow::imageOriginlUploadB()
  {
      dir_Original_B = QFileDialog::getExistingDirectory(this, tr("Choose an image directory to load"),
                                                       filesListRight, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
      if(dir_Original_B.length() &gt; 0){
          QImage image;
          QDir dirBObj(dir_Original_B);
          QStringList filesListRight = dirBObj.entryList(QDir::NoDotAndDotDot | QDir::System | QDir::Hidden  | QDir::AllDirs | QDir::Files, QDir::DirsFirst);
          ui-&gt;labelOrigImageB-&gt;setPixmap(QPixmap::fromImage(image.scaled(125,125,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
          for ( int i = 0 ; i &lt; filesListRight.size() ; i++ )
          {
              ui-&gt;listWidgetOriginalImgB-&gt;addItem(filesListRight.at(i));
          }
          ui-&gt;listWidgetOriginalImgB-&gt;update();
          ui-&gt;labelOrigImageB-&gt;show();
      }
  }
  
  
  void MainWindow::on_originalmgB_clicked()
  {
      imageOriginlUploadB();
  }
  </code></pre>
  
  <p>or here is resizing the <code>QGraphicsView</code> using a <code>QPushButton</code>:</p>
  
  <pre><code>void MainWindow::on_fitViewBtn_clicked()
  {
      ui-&gt;graphicsViewLX-&gt;fitInView(mLeftScene-&gt;sceneRect(), Qt::KeepAspectRatio);
      ui-&gt;graphicsViewRX-&gt;fitInView(mRightScene-&gt;sceneRect(), Qt::KeepAspectRatio);
  }
  </code></pre>
  
  <p>And this is the activation of a <code>QCheckBox</code>:</p>
  
  <pre><code>void MainWindow::on_checkBoxScreen_A_toggled(bool checked)
  {
      if(ui-&gt;checkBoxScreen_A-&gt;isEnabled()) {
          if(checked)
          {
              ui-&gt;checkBoxScreen_A-&gt;setText("Active");
              ui-&gt;saveToFile_A-&gt;setEnabled(true);
              ui-&gt;saveToFile_A-&gt;setStyleSheet("QPushButton{ background-color: green }");
          }
          else {
              ui-&gt;checkBoxScreen_A-&gt;setText("Inactive");
              ui-&gt;saveToFile_A-&gt;setEnabled(false);
              ui-&gt;saveToFile_A-&gt;setStyleSheet("QPushButton{ background-color: grey }");
          }
      }
  }
  </code></pre>
  
  <p>How to achieve that? 
  Thank you very much for pointing in the right direction</p>