title: Passing signals through hierarchies
body: <p>I am having some difficulty fully grasping how signals and slots are used in Qt. I am sure it is really basic but I'm just no getting it today.</p>
  
  <p>I have a set of widgets a bit like this:</p>
  
  <p>MainWindow
  -->StackedWidget
     -->ChildForms</p>
  
  <p>Now the idea is that there are some actions on the Child widgets that will cause the stacked widget to display a different page.</p>
  
  <p>So if I understand it properly I thought the way to connect signals and slots is to use the <code>connect()</code> at the scope that knows about the objects but what I have managed to get working doesn't do it this way. At the moment in my child form I use parentWidget() to access the slot of the StackedWidget but I am not very happy with really because it is giving the child information about the parent which it shouldn't have:</p>
  
  <pre><code>void TaskSelectionForm::setButtonMappings()
  {
      // Set up a mapping between the buttons and the pages
      QSignalMapper *mapper = new QSignalMapper(this);
      connect(mapper, SIGNAL(mapped(int)), parentWidget(), SLOT(setCurrentIndex(int)));
  
      mapper-&gt;setMapping(ui-&gt;utilitiesButton, 2); // Value of the index
      connect(ui-&gt;utilitiesButton, SIGNAL(clicked()), mapper, SLOT(map()));
  }
  </code></pre>
  
  <p>But I am not really sure how I should do this and connect it up. Do I need to have signals at each level and emit through the tree?</p>