int main()
{
//! [1]
    Counter a, b;
//! [1] //! [2]
    QObject::connect(&a, SIGNAL(valueChanged(int)),
                     &b, SLOT(setValue(int)));
//! [2]

//! [3]
    a.setValue(12);     // a.value() == 12, b.value() == 12
//! [3] //! [4]
    b.setValue(48);     // a.value() == 12, b.value() == 48
//! [4]


    QWidget *widget = reinterpret_cast<QWidget *>(new QObject(0));
//! [5]
    if (widget->inherits("QAbstractButton")) {
        QAbstractButton *button = static_cast<QAbstractButton *>(widget);
        button->toggle();
//! [5] //! [6]
    }
//! [6]

//! [7]
    if (QAbstractButton *button = qobject_cast<QAbstractButton *>(widget))
        button->toggle();
//! [7]
}
/*!
  When one of the 6 coordinate check boxes is clicked, this checks to see
  how many are already selected.  It only allows a box to be checked if there
  are fewer than 3 boxes already checked.  If there are 3 checked, the OK
  button is enabled, otherwise it is disabled.  \a whichFixed keeps track of
  the indexes of the currently selected check boxes.
*/
void GWSProjDlg::coordBoxClicked(int buttonNum)
{
  QAbstractButton *b = coordButtonGroup->button(buttonNum);
  if (b->isChecked()) {
    if (whichFixed.size() < 3) {
      whichFixed.insert(buttonNum);
      if (whichFixed.size() == 3) { OKButton->setEnabled(true); }
    }
    else {
      b->toggle();
    }
  }
  else {
    whichFixed.erase(buttonNum);
    OKButton->setEnabled(false);
  }
}
void ClsQNeuronStateVariableDisplay::setSelectedStates(list<string> lstStates) {
#ifdef DEBUG_CLSQSTATEVARIABLEDISPLAY
    cout << "ClsQNeuronStateVariableDisplay::setSelectedStates(list<string> lst)" << endl;
#endif

    QList<QAbstractButton *> lst = qbtngrpStateVariables->buttons ();
    QList<QAbstractButton*>::iterator it;

    for (it = lst.begin(); it != lst.end(); ++it) {
	string str= (string)((*it)->text().latin1());
	if(std::find(lstStates.begin(), lstStates.end(), str) != lstStates.end()){
	    QAbstractButton *qrb = (*it);
	    qrb->toggle();
 
	    string strSinkID = qrb->text().latin1() + strID;
	    QColor qc;	    
	    qc.setHsv(clsFEDataClient->getDataSinkColor(strSinkID), 255, 210);
	    QPalette palette = qrb->palette();
	    palette.setColor ( QColorGroup::Foreground, qc );
//	    palette.setColor ( QColorGroup::ButtonText, qc );
	    qrb->setPalette(palette);
	}
    }
};