title: Passing QClipboard to QML
body: <p>I am trying to make the clipboard available to some QML code.</p>
  
  <p>Passing the clipboard object seems to work, but then I can't call its methods.</p>
  
  <p>Here's an example of a QClipboard working fine in C++, being passed to QML, and in the debug output it still being a QClipboard object but losing its functions.</p>
  
  <p><strong>main.cpp</strong></p>
  
  <pre><code>#include &lt;QApplication&gt;
  #include &lt;QClipboard&gt;
  #include &lt;QQmlApplicationEngine&gt;
  #include &lt;qqmlcontext.h&gt;
  #include &lt;QtQml&gt;
  
  
  int main(int argc, char *argv[]) {
      QApplication app(argc, argv);
  
      QQmlApplicationEngine engine;
      engine.rootContext()-&gt;setContextProperty("clipboard", QApplication::clipboard());
      qDebug() &lt;&lt; QApplication::clipboard()-&gt;text(); // This correctly prints the copied text
      engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
      return app.exec();
  }
  </code></pre>
  
  <p><strong>main.qml</strong></p>
  
  <pre><code>import QtQuick 2.5
  import QtQuick.Controls 1.3
  ApplicationWindow {
      visible: true
      MouseArea {
          acceptedButtons: Qt.MiddleButton
          anchors.fill: parent
          onClicked: {
              console.log(clipboard)
              console.log(clipboard.getText())
          }
      }
  }
  </code></pre>
  
  <p><strong>qml.qrc</strong></p>
  
  <pre><code>&lt;RCC&gt;
      &lt;qresource prefix="/"&gt;
          &lt;file&gt;main.qml&lt;/file&gt;
      &lt;/qresource&gt;
  &lt;/RCC&gt;
  </code></pre>
  
  <p><strong>test.pro</strong></p>
  
  <pre><code>TEMPLATE = app
  VERSION = 1.0
  
  QT += qml widgets gui
  QMAKE_LFLAGS += -Wl,--as-needed
  
  SOURCES += main.cpp
  RESOURCES += qml.qrc
  </code></pre>