1

How do we assign a QButtonGroup to a layout?

radioLayout = QtGui.QHBoxLayout() 
radioGroup=QtGui.QButtonGroup()
radioLayout.addWidget(radioGroup)

Getting TypeError error on the last line trying to add radioGroup to the layout. What would be a correct way?

styvane
  • 59,869
  • 19
  • 150
  • 156
alphanumeric
  • 17,967
  • 64
  • 244
  • 392
  • 3
    A `QButtonGroup` is not a visual item (a.k.a. widget) that can be placed in a layout. It is merely a container for managing the states of the buttons in the group. – RA. Nov 24 '15 at 02:20
  • 3
    Possible duplicate of [grouping radio buttons in PyQt](http://stackoverflow.com/questions/14798058/grouping-radio-buttons-in-pyqt) – tomvodi Nov 24 '15 at 08:29

1 Answers1

0

QButtonGroup is not a Qwidget, it's a comfortable implementation of List<QPushButton>, of course, you can add all buttons into QLayout but it's more difficult than simple addWidget method, so code:

QList<QAbstractButton*> buttonList=m_buttonGroup->buttons();
    for (QList<QAbstractButton*>::const_iterator it=buttonList.cbegin(); it!=buttonList.cend(); ++it)
    {
        layout->addWidget(*it);
    }