title: How do I react to a QML button click in C++
body: <p>I am trying to launch a different QML Page from my C++ code by hooking into the clicked() slot of a button in my QML but it's not working.</p>
  
  <pre><code>    Button {
          objectName: btnLogin
          text: qsTr("Login")
          id: btnLogin
      }
  </code></pre>
  
  <p>And the c++</p>
  
  <pre><code>QObject *newButton = root-&gt;findChild&lt;QObject*&gt;("btnLogin");
  QObject::connect(newButton, SIGNAL(clicked()), this, SLOT(loginClick()));
  </code></pre>
  
  <p>The slots in my hpp file:</p>
  
  <pre><code> public slots:  
      void loginClick();
  </code></pre>
  
  <p>And my clicked method:</p>
  
  <pre><code>void GConnectBB::loginClick() {
      int i = 0;
  
      Button *newButton = root-&gt;findChild&lt;Button*&gt;("btnLogin");
      if (newButton)
          newButton-&gt;setProperty("text", "New button text");
  }
  
  
  QObject *newButton = root-&gt;findChild&lt;QObject*&gt;("btnLogin"); 
  </code></pre>
  
  <p>Is null when I check through the debugger. I am extremely rusty with C++ and completely new to Qt, please be gentle :) What could I be doing wrong?</p>