一、概述
QRadioButton是制作单选的极佳控件,下面是其简单使用介绍。
本案例的用途:切换上采样及下采样。
示例图:
二、示例代码
QButtonGroup* group = new QButtonGroup(this); QRadioButton* btn1 = new QRadioButton(this); btn1->setText("上采样"); QRadioButton* btn2 = new QRadioButton(this); btn2->setText("降采样"); group->addButton(btn1, 0); group->addButton(btn2, 1); QHBoxLayout* radioLayout = new QHBoxLayout(this); radioLayout->addWidget(btn1); radioLayout->addWidget(btn2); connect(btn1, &QRadioButton::clicked, this, [=]() { //QMessageBox::information(this, "上采样", "这是一个上采样弹框"); this->mType = 1; this->execute(); }); connect(btn2, &QRadioButton::clicked, this, [=]() { this->mType = 0; this->execute(); //QMessageBox::information(this, "降采样", "这是一个降采样弹框"); });
标签:采样,简单,QRadioButton,使用,radioLayout,new,btn1,btn2 From: https://www.cnblogs.com/tony-yang-flutter/p/17898694.html