title: get value of an object in another class
body: <p>How to get value of an object in another class? Such as I have 2 classes (class WidgetA and class WidgetB) both those classes are created by class Widget, like this:</p>
  
  <pre><code>//widget.h
  
  #include &lt;QWidget&gt;
  #include &lt;QtGui&gt;
  
  class widgetA;
  class widgetB;
  
  class Widget : public QWidget
  {
      Q_OBJECT
  public:
      explicit Widget(QWidget *parent = 0);
  private:
      QComboBox* comboBox;
      QStackedWidget* stackWidget;
      widgetA *wa;
      widgetB *wb;
  };
  
  class widgetA : public QWidget
  {
      Q_OBJECT
  public:
      widgetA(QWidget *parent = 0);
  private:
      QString mystr;
      QLineEdit* lineEdit;
  };
  
  class widgetB : public QWidget
  {
      Q_OBJECT
  
  public:
      widgetB(QWidget *parent = 0);
      QLabel* label;
  };
  </code></pre>
  
  <p>And this is file widget.cpp:</p>
  
  <pre><code>#include "widget.h"
  
  Widget::Widget(QWidget *parent) :
      QWidget(parent)
  {
      comboBox = new QComboBox(this);
      comboBox-&gt;addItem(tr("Widget A"));
      comboBox-&gt;addItem(tr("Widget B"));
  
      wa = new widgetA(this);
      wb = new widgetB(this);
  
      stackWidget = new QStackedWidget(this);
      stackWidget-&gt;addWidget(wa);
      stackWidget-&gt;addWidget(wb);
      stackWidget-&gt;setCurrentIndex(0);
  
      connect(comboBox, SIGNAL(currentIndexChanged(int)), stackWidget, SLOT(setCurrentIndex(int)));
  
      QVBoxLayout* layout = new QVBoxLayout;
      layout-&gt;addWidget(comboBox);
      layout-&gt;addWidget(stackWidget);
  
      setLayout(layout);
  }
  
  widgetA::widgetA(QWidget *parent):
      QWidget(parent)
  {
      lineEdit = new QLineEdit;
      QHBoxLayout *lay = new QHBoxLayout;
      lay-&gt;addWidget(lineEdit);
      lineEdit-&gt;setReadOnly(true);
  
      setLayout(lay);
  }
  
  
  widgetB::widgetB(QWidget *parent):
      QWidget(parent)
  {
      label = new QLabel("Hello QT");
      QHBoxLayout* lay = new QHBoxLayout;
      lay-&gt;addWidget(label);
      setLayout(lay);
  }
  </code></pre>
  
  <p>How to I get text of QLabel <code>label</code> in WidgetB class into QString <code>mystr</code> in WidgetA class?</p>