title: (Qt C++) How to print chosen files/folders into a text file from a QTableView
body: <p>I have a QTableView *tableView. When an user chooses the files / folders in tableView and right click -> choose "Print these items", I want my program to print those names into a text file or assign to a string. How can I do that? Thank you.</p>
  
  <p>frmainwindow.h:</p>
  
  <pre><code>private slots:
      void showContextMenuRequested(QPoint pos); 
  </code></pre>
  
  <p>frmainwindow.cpp:</p>
  
  <pre><code>#include "frmainwindow.h"
  #include "ui_frmainwindow.h"
  
  FrMainWindow::FrMainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::FrMainWindow)
  {
      ui-&gt;setupUi(this);
      model1-&gt;setRootPath("c:\\");
      ui-&gt;tableView-&gt;setModel(model1);
      connect(ui-&gt;tableView, SIGNAL(customContextMenuRequested(QPoint)), this,
              SLOT (showContextMenuRequested(QPoint)));
  }
  
  FrMainWindow::~FrMainWindow()
  {
      delete ui;
  }
  
  void FrMainWindow::showContextMenuRequested(QPoint pos)
  {
      QMenu *contextMenu = new QMenu(this);
      contextMenu-&gt;addAction(new QAction("Print these items", this));
      contextMenu-&gt;popup(ui-&gt;tableView-&gt;viewport()-&gt;mapToGlobal(pos));
  }
  </code></pre>