title: How to draw with QPainter on a specific widget from a group of widgets in QMainWindow?
body: <p>This is my code:</p>
  
  <pre><code>#include "mainwindow.h"
  #include &lt;QDebug&gt;
  
  #include &lt;QCameraInfo&gt;
  #include &lt;QHBoxLayout&gt;
  #include &lt;fstream&gt;
  #include &lt;assert.h&gt;
  
  MainWindow::MainWindow(QWidget *parent)
      : QMainWindow(parent)
  {
      m_QPushButton_calibration = new QPushButton("Calibrate", this);
      connect(m_QPushButton_calibration, SIGNAL (released()),this, SLOT (handleButton()));
  
      QList&lt;QCameraInfo&gt; l_QListQCameraInfo_available_cameras = QCameraInfo::availableCameras();
  
      m_QWidget_viewfinder_holder    = new QWidget;
      m_QWidget_viewfinder_holder-&gt;setStyleSheet ("background-color: black");
  
      m_QCameraViewfinder_viewfinder = new QCameraViewfinder(m_QWidget_viewfinder_holder);
  
      if (l_QListQCameraInfo_available_cameras.length() &gt;= 2)
      {
          m_QCamera_required_camera = new QCamera (l_QListQCameraInfo_available_cameras[1]);
  
          m_QCamera_required_camera-&gt;setViewfinder(m_QCameraViewfinder_viewfinder);
          m_QCamera_required_camera-&gt;start ();
      }
  
      m_QWidget_central     = new QWidget;
      m_QGridLayout_central = new QGridLayout;
  
      m_QWidget_central-&gt;setLayout (m_QGridLayout_central);
  
      m_QGridLayout_central-&gt;addWidget (m_QPushButton_calibration, 0, 0, 1, 1);
      m_QGridLayout_central-&gt;addWidget (m_QWidget_viewfinder_holder, 1, 0, 1, 1);
  
      this-&gt;setCentralWidget (m_QWidget_central);
  
      m_QCameraViewfinder_viewfinder-&gt;show();
  }
  
  void MainWindow::paintEvent(QPaintEvent *)
  {
      QPainter painter(this);
      painter.setPen(Qt::white);
      painter.setFont(QFont("Arial", 30));
      painter.drawText(rect(), Qt::AlignCenter, "Qt");
  }
  
  MainWindow::~MainWindow()
  {
      delete m_QPushButton_calibration;
      delete m_QCameraViewfinder_viewfinder;
      delete m_QCamera_required_camera;
      delete m_QGridLayout_central;
      delete m_QWidget_central;
  }
  
  void MainWindow::handleButton()
  {
      qDebug() &lt;&lt; "handleButton";
  }
  </code></pre>
  
  <p>I actually wish to draw a line on <code>m_QWidget_viewfinder_holder</code> widget.</p>
  
  <ol>
  <li><p><strong>How will that <code>QPaintEvent</code> function know where do I want it to draw line?</strong></p></li>
  <li><p><strong>Can I use <code>QPaintEvent</code> as a member function in a class inherited from <code>QMainWindow</code>?</strong></p></li>
  </ol>