title: How to lay a QQuickWidget (with transparency) on top of a QWidget
body: <p>I'm trying to use a <strong>QQuickWidget</strong> as an overlay over a <strong>QWidget</strong>.  The <strong>QQuickWidget</strong> contains some buttons and a couple other widgets laid out along the bottom.</p>
  
  <p>I've found that I can get the <strong>QQuickWidget</strong> to properly overlay the <strong>QWidget</strong> by using a combination of <strong>setAttribute(Qt::WA_AlwaysStackOnTop)</strong> and <strong>setClearColor(Qt::transparent)</strong>.  But the problem I'm having is that all the mouse events are being directed to the main window instead of the underlying <strong>QWidget</strong>.</p>
  
  <p>I setup a sample project to reproduce my problem.</p>
  
  <p><strong>OverlayItem.qml</strong> is defined as follows:</p>
  
  <pre><code>import QtQuick 2.6
  import QtQuick.Controls 1.4
  
  Item {
      width: parent.width
      height: parent.height
  
      Row {
          anchors { 
              horizontalCenter: parent.horizontalCenter; 
              bottom: parent.bottom; 
              bottomMargin: 15 
          }
          spacing: 15
          Button {
              text: "Button1"
              onClicked: {
                  console.log("Button1 CLICKED!")
              }
          }
          Button {
              text: "Button2"
              onClicked: {
                  console.log("Button2 CLICKED!")
              }
          }
          Button {
              text: "Button3"
              onClicked: {
                  console.log("Button3 CLICKED!")
              }
          }
      }
  }
  </code></pre>
  
  <p>The QQuickWidget is created and the QML loaded when <strong>MainWindow</strong> is created:</p>
  
  <pre><code>MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow),
      qw(NULL)
  {
      ui-&gt;setupUi(this);
  
      qw = new QQuickWidget(ui-&gt;frame);
      qw-&gt;setResizeMode(QQuickWidget::SizeRootObjectToView);
      qw-&gt;setAttribute(Qt::WA_AlwaysStackOnTop);
      qw-&gt;setClearColor(Qt::transparent);
      qw-&gt;setSource(QUrl("OverlayItem.qml"));
  }
  
  void MainWindow::showEvent(QShowEvent *event)
  {
      if (auto pw = qw-&gt;parentWidget())
      {
          qw-&gt;resize(pw-&gt;size());
      }
  }
  
  void MainWindow::resizeEvent(QResizeEvent *event)
  {
      if (auto pw = qw-&gt;parentWidget())
      {
          qw-&gt;resize(pw-&gt;size());
      }
  }
  </code></pre>
  
  <p>And here's the MainWindow UI code:</p>
  
  <pre><code>class Ui_MainWindow
  {
  public:
      QWidget *centralWidget;
      QGridLayout *gridLayout_2;
      QFrame *frame;
      QGridLayout *gridLayout;
      QTextBrowser *textBrowser;
  
      void setupUi(QMainWindow *MainWindow)
      {
          if (MainWindow-&gt;objectName().isEmpty())
              MainWindow-&gt;setObjectName(QStringLiteral("MainWindow"));
          MainWindow-&gt;resize(800, 600);
  
          QSizePolicy sizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
          sizePolicy.setHorizontalStretch(0);
          sizePolicy.setVerticalStretch(0);
          sizePolicy.setHeightForWidth(MainWindow-&gt;sizePolicy().hasHeightForWidth());
          MainWindow-&gt;setSizePolicy(sizePolicy);
  
          centralWidget = new QWidget(MainWindow);
          centralWidget-&gt;setObjectName(QStringLiteral("centralWidget"));
  
          gridLayout_2 = new QGridLayout(centralWidget);
          gridLayout_2-&gt;setSpacing(6);
          gridLayout_2-&gt;setContentsMargins(11, 11, 11, 11);
          gridLayout_2-&gt;setObjectName(QStringLiteral("gridLayout_2"));
  
          frame = new QFrame(centralWidget);
          frame-&gt;setObjectName(QStringLiteral("frame"));
          frame-&gt;setFrameShape(QFrame::StyledPanel);
          frame-&gt;setFrameShadow(QFrame::Raised);
  
          gridLayout = new QGridLayout(frame);
          gridLayout-&gt;setSpacing(6);
          gridLayout-&gt;setContentsMargins(11, 11, 11, 11);
          gridLayout-&gt;setObjectName(QStringLiteral("gridLayout"));
  
          textBrowser = new QTextBrowser(frame);
          textBrowser-&gt;setObjectName(QStringLiteral("textBrowser"));
          textBrowser-&gt;setReadOnly(false);
  
          gridLayout-&gt;addWidget(textBrowser, 0, 0, 1, 1);
  
          gridLayout_2-&gt;addWidget(frame, 0, 0, 1, 1);
  
          MainWindow-&gt;setCentralWidget(centralWidget);
  
          retranslateUi(MainWindow);
  
          QMetaObject::connectSlotsByName(MainWindow);
      } // setupUi
  };
  </code></pre>
  
  <p>As you can see, the CentralWidget contains a <strong>QFrame</strong> which, in turn, contains a <strong>QTextBrowser</strong>.  The desired behavior of this example code is for the <strong>QTextBrowser</strong> to remain functional while 3 buttons are overlaid at the bottom.  However, when I run this code, I'm unable to click on the <strong>QTextBrowser</strong> in order to give it focus.  Instead, <strong>MainWindow</strong> receives all of the non-button-click mouse events.</p>
  
  <p>I've played around with event filters and reparenting, but I don't seem to be getting anywhere.  Has anyone had success trying something like this?</p>