Home > Back-end >  QButtonGroup QT problem
QButtonGroup QT problem

Time:09-17

Excuse me,, I now have a demand to be this way
There are a lot of buttons, each column is a QButtonGroup, between the same column button is mutually exclusive, then how can I pass a for loop to each column a button to make a table ah, I am Tony, a trouble, grant instruction!
Now I wrote this
 m_pHLayout=new QHBoxLayout (); 

QGridLayout * m_pBtnLayout1=new QGridLayout ();

QButtonGroup * m_pBtnGroup1=new QButtonGroup ();

for(int i=0; I & lt; 16. I++)
{
CustomBtn * m_pBtn=new CustomBtn ();

M_pBtn - & gt; SetText (QString (" % 1 "). Arg (I + 1));

M_pBtn - & gt; SetCheckable (true);//set can be selected to

M_pBtnGroup1 - & gt; AddButton (m_pBtn, I);

M_pBtnLayout1 - & gt; AddWidget (m_pBtn);

}
M_pBtnGroup1 - & gt; SetExclusive (true);//set mutex

The connect (m_pBtnGroup1, SIGNAL (buttonClicked (int)), and this, SLOT (slotCurrentIndex (int)));

M_pHLayout - & gt; AddLayout (m_pBtnLayout1);

This - & gt; SetLayout (m_pHLayout);
  • Related