// QGroupBox 互斥勾选框
void mutexGroupBoxCheck(QList< QGroupBox *> groupList)
{
for(auto group:groupList)
{
if(group)
{
QGroupBox::connect(group,&QGroupBox::clicked,[=]{
bool check = group->isChecked();
for(auto it:groupList)
{
if(it && it !=group)
{
it->setChecked(!check);
}
}
});
}
}
}
例子:
mutexGroupBoxCheck(QList< QGroupBox *>() << ui->gbxDevicePortAdptive <<ui->gbxDeviceIPAdptive );