title: How to recognize QMouseEvent inside child widgets?
body: <hr>
  
  <p>EDIT and Some Self Critisicm
  I tried both given solutions, which both solved my problem, and thus I thank you both! I marked the transparent solution as accepted because I thought it is was the easiest implementation when I only had one child widget, but I wish to share some insight for other beginners:</p>
  
  <p>I first used <code>QLabel</code>, which apperently has enabled <code>Qt::WA_TransparentForMouseEvents</code> by default and thus obviously worked, but I also wanted the text to be selectable, by using <code>QPlainTextEdit</code> instead. Laughably, this is not possible in any way, because if you try to select the text (by clicking) you will close the window! I ended up keeping the transparancy, and neglecting the select-text-feature.</p>
  
  <hr>
  
  <p>I'm guessing my following question has been answered somewhere before, but after an hour of searching I now post the question myself. I'm grateful if someone can point me to an already answered question that solves my problem.</p>
  
  <p>Anyhow, I'm creating a popup window, using C++ and Qt. I've created the following <code>PopupDialog</code> class which works well and fine for all its purposes. However, I've removed its frame (including the bar containing the close button and window title) to make it look minimalistic, and now I want it to close if the user presses/releases the mouse button anywhere inside the popup window (dialog).</p>
  
  <p>The below code works, however in such a way that I have to click and release the mouse exactly at the QDialog-window itself. It will not close when i click if the mouse hovers over the child widget(s) inside the <code>QDialog</code>, e.g. a <code>QPlainTextEdit</code>, which is displaying text.</p>
  
  <p><strong>Hence, I'm in need of a solution for <code>QDialog</code> to recognize <code>QMouseEvents</code> inside its child widgets</strong>. Please, don't hesitate to ask if something is unclear. I have not included my mainwindow.h/.cpp files, or <code>popupdialog.ui</code> file since I believe it would be a little too much to post here, but the <code>.ui</code> extremely simple: Just the <code>QDialog</code> window holding a <code>QBoxLayout</code>, containing a single widget, a <code>QPlainTextEdit</code>. I may posts these on request if it helps.</p>
  
  <pre><code>    // popupdialog.h
  
      #ifndef POPUPDIALOG_H
      #define POPUPDIALOG_H
  
      #include &lt;QDialog&gt;
      #include &lt;QString&gt;
  
      namespace Ui {class PopupDialog;}
  
      class PopupDialog : public QDialog
      {
              Q_OBJECT
  
      public:
              explicit PopupDialog(QWidget *parent = 0, QString msgTxt="");
              ~PopupDialog();
  
      private:
              Ui::PopupDialog *ui;
              QString messageText;
              void mouseReleaseEvent(QMouseEvent*);
      };
  
      #endif //POPUPDIALOG_H
  </code></pre>
  
  <p>...</p>
  
  <pre><code>    // popupdialog.cpp
  
      #include "popupdialog.h"
      #include "ui_popupdialog.h"
  
  
      PopupDialog::PopupDialog(QWidget *parent, QString msgTxt) :
              QDialog(parent),
              ui(new Ui::PopupDialog),
              messageText(msgTxt)
      {
              ui-&gt;setupUi(this);
              setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
              setModal(true);
              ui-&gt;message_text_display-&gt;setText(messageText);
              // The message_text_display is an instance of the class,
              // "PlainTextEdit". Using "QLabel" partly solves my
              // problem, but does not allow text selection.
      }
  
      PopupDialog::~PopupDialog()
      {
              delete ui;
      }
  
  
      void PopupDialog::mouseReleaseEvent(QMouseEvent *e)
      {
              this-&gt;close();
      }
  </code></pre>