单选框, 复选框
    image.png

    1. Widget::Widget(QWidget *parent)
    2. : QWidget(parent)
    3. , ui(new Ui::Widget)
    4. {
    5. ui->setupUi(this);
    6. //单选框
    7. ui->RDB_Men->setChecked(true); //设置默认属性
    8. connect(ui->RDB_Women,&QRadioButton::clicked,[=](){
    9. qDebug() << "选中女";
    10. });
    11. //多选框,选中为2,未选中为0,半选中为1
    12. connect(ui->checkBox,&QCheckBox::stateChanged,[=](int state){
    13. qDebug() << state;
    14. });
    15. }