本文整理汇总了C++中QRadioButton类的典型用法代码示例。如果您正苦于以下问题:C++ QRadioButton类的具体用法?C++ QRadioButton怎么用?C++ QRadioButton使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QRadioButton类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QGroupBox
QGroupBox *ServerDialog::createGameModeBox(){
QGroupBox *mode_box = new QGroupBox(tr("Game mode"));
mode_group = new QButtonGroup;
QVBoxLayout *layout = new QVBoxLayout;
{
// normal modes
QMap<QString, QString> modes = Sanguosha->getAvailableModes();
QMapIterator<QString, QString> itor(modes);
while(itor.hasNext()){
itor.next();
QRadioButton *button = new QRadioButton(itor.value());
button->setObjectName(itor.key());
layout->addWidget(button);
mode_group->addButton(button);
if(itor.key() == Config.GameMode)
button->setChecked(true);
}
}
{
// add scenario modes
QRadioButton *scenario_button = new QRadioButton(tr("Scenario mode"));
scenario_button->setObjectName("scenario");
layout->addWidget(scenario_button);
mode_group->addButton(scenario_button);
scenario_combobox = new QComboBox;
QStringList names = Sanguosha->getScenarioNames();
foreach(QString name, names){
QString scenario_name = Sanguosha->translate(name);
const Scenario *scenario = Sanguosha->getScenario(name);
int count = scenario->getPlayerCount();
QString text = tr("%1 (%2 persons)").arg(scenario_name).arg(count);
scenario_combobox->addItem(text, name);
}
layout->addWidget(scenario_combobox);
if(mode_group->checkedButton() == NULL){
int index = names.indexOf(Config.GameMode);
if(index != -1){
scenario_button->setChecked(true);
scenario_combobox->setCurrentIndex(index);
}
}
}
示例2: RKComponent
RKRadio::RKRadio (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget) : RKComponent (parent_component, parent_widget) {
RK_TRACE (PLUGIN);
// create and register properties
addChild ("string", string = new RKComponentPropertyBase (this, false));
connect (string, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (propertyChanged (RKComponentPropertyBase *)));
addChild ("number", number = new RKComponentPropertyInt (this, true, -1));
connect (number, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (propertyChanged (RKComponentPropertyBase *)));
// get xml-helper
XMLHelper *xml = XMLHelper::getStaticHelper ();
// create layout
QVBoxLayout *vbox = new QVBoxLayout (this, RKGlobals::spacingHint ());
// create ButtonGroup
group = new QButtonGroup (xml->getStringAttribute (element, "label", i18n ("Select one:"), DL_INFO), this);
// create internal layout for the buttons in the ButtonGroup
group->setColumnLayout (0, Qt::Vertical);
group->layout()->setSpacing (RKGlobals::spacingHint ());
group->layout()->setMargin (RKGlobals::marginHint ());
QVBoxLayout *group_layout = new QVBoxLayout (group->layout(), RKGlobals::spacingHint ());
// create all the options
XMLChildList option_elements = xml->getChildElements (element, "option", DL_ERROR);
int checked = 0;
int i = 0;
for (XMLChildList::const_iterator it = option_elements.begin (); it != option_elements.end (); ++it) {
QRadioButton *button = new QRadioButton (xml->getStringAttribute (*it, "label", QString::null, DL_ERROR), group);
options.insert (i, xml->getStringAttribute (*it, "value", QString::null, DL_WARNING));
group_layout->addWidget (button);
if (xml->getBoolAttribute (*it, "checked", false, DL_INFO)) {
button->setChecked (true);
checked = i;
}
++i;
}
updating = false;
number->setIntValue (checked); // will also take care of checking the correct button
number->setMin (0);
number->setMax (i-1);
vbox->addWidget (group);
connect (group, SIGNAL (clicked (int)), this, SLOT (buttonClicked (int)));
// initialize
buttonClicked (group->selectedId ());
}
示例3: LOG_MSG
//------------------------------------------------------------------------------------------------
// To create the group of radiobuttons for field constituent selection.
// This uses information about active constituents fetched from the DLL.
// Need to distinguish field constituent from cell constituent, because for the
// field we have only the dissolved constituents:
// oxygen, glucose, drugA, drugB, metabolites...
//------------------------------------------------------------------------------------------------
void Field::setFieldConstituentButtons(QGroupBox *gbox, QButtonGroup *bg, QVBoxLayout **vbox, QList<QRadioButton *> *rb_list, QString tag)
{
int ivar;
QString name, str, ivar_str;
QRadioButton *rb;
Global::nfieldvars_used = Global::nvars_used - Global::N_EXTRA;
// LOG_QMSG("setFieldConstituentButtons: " + tag + " nfieldvars_used: "
// + QString::number(Global::nfieldvars_used));
if (rb_list->length() != 0) {
LOG_MSG("rb_list not NULL, delete it");
for (ivar=0; ivar<rb_list->length(); ivar++) {
rb = (*rb_list)[ivar];
bg->removeButton(rb);
delete rb;
}
rb_list->clear();
}
if (!*vbox) {
LOG_MSG("vbox = NULL, create it");
*vbox = new QVBoxLayout;
gbox->setLayout(*vbox);
}
name = "rb_field_constituent_"+tag;
// LOG_QMSG(name);
for (ivar=0; ivar<Global::nfieldvars_used; ivar++) {
ivar_str = QString::number(ivar);
str = Global::var_string[ivar+1];
rb = new QRadioButton;
rb->setText(str);
QString objname = name+ivar_str;
rb->setObjectName(objname);
(*vbox)->addWidget(rb);
rb->setEnabled(true);
bg->addButton(rb,ivar);
rb_list->append(rb);
// QRadioButton *chkrb = gbox->findChild<QRadioButton *>(objname);
// if (chkrb) {
// QString chkstr = chkrb->objectName();
// LOG_QMSG(chkstr);
// } else {
// chkrb = (*rb_list)[ivar];
// LOG_QMSG("findChild failed, but: " + chkrb->objectName());
// }
}
(*rb_list)[0]->setChecked(true); // Oxygen
QRect rect = gbox->geometry();
rect.setHeight(25*(Global::nfieldvars_used + 1));
gbox->setGeometry(rect);
gbox->show();
}
示例4: QButtonGroup
QWidget * ExtArgRadio::createEditor(QWidget * parent)
{
int count = 0;
bool anyChecked = false;
selectorGroup = new QButtonGroup(parent);
QWidget * radioButtons = new QWidget;
QVBoxLayout * vrLayout = new QVBoxLayout();
QMargins margins = vrLayout->contentsMargins();
vrLayout->setContentsMargins(0, 0, 0, margins.bottom());
if ( callStrings != 0 )
delete callStrings;
callStrings = new QList<QString>();
if ( values.length() > 0 )
{
ExtcapValueList::const_iterator iter = values.constBegin();
while ( iter != values.constEnd() )
{
QRadioButton * radio = new QRadioButton((*iter).value());
QString callString = (*iter).call();
callStrings->append(callString);
if ( (*iter).isDefault() )
{
radio->setChecked(true);
anyChecked = true;
}
connect(radio, SIGNAL(clicked(bool)), SLOT(onBoolChanged(bool)));
selectorGroup->addButton(radio, count);
vrLayout->addWidget(radio);
count++;
++iter;
}
}
/* No default was provided, and not saved value exists */
if ( anyChecked == false && count > 0 )
((QRadioButton*)(selectorGroup->button(0)))->setChecked(true);
radioButtons->setLayout(vrLayout);
return radioButtons;
}
示例5: QGroupBox
void mtsIntuitiveResearchKitConsoleQtWidget::setupUi(void)
{
QGridLayout * frameLayout = new QGridLayout;
QGroupBox * groupBox = new QGroupBox("Desired state");
QRadioButton * idleButton = new QRadioButton("Idle");
QRadioButton * homeButton = new QRadioButton("Home");
QRadioButton * teleOpButton = new QRadioButton("Teleop");
// QRadioButton * gcButton = new QRadioButton("Gravity");
// QRadioButton * clutchButton = new QRadioButton("Clutch");
idleButton->setChecked(true);
QButtonGroup * group = new QButtonGroup;
group->addButton(idleButton);
group->addButton(homeButton);
group->addButton(teleOpButton);
// group->addButton(gcButton);
// group->addButton(clutchButton);
group->setExclusive(true);
QVBoxLayout * vbox = new QVBoxLayout;
vbox->addWidget(idleButton);
vbox->addWidget(homeButton);
vbox->addWidget(teleOpButton);
// vbox->addWidget(gcButton);
// vbox->addWidget(clutchButton);
vbox->addStretch(1);
groupBox->setLayout(vbox);
frameLayout->addWidget(groupBox, 0, 0);
QTEMessages = new QTextEdit();
QTEMessages->setReadOnly(true);
QTEMessages->ensureCursorVisible();
frameLayout->addWidget(QTEMessages, 0, 1);
QVBoxLayout * mainLayout = new QVBoxLayout;
mainLayout->addLayout(frameLayout);
setLayout(mainLayout);
setWindowTitle("Intuitive Research Kit");
resize(sizeHint());
connect(group, SIGNAL(buttonClicked(QAbstractButton*)),
this, SLOT(SlotSetStateButton(QAbstractButton*)));
connect(this, SIGNAL(SignalAppendMessage(QString)),
QTEMessages, SLOT(append(QString)));
connect(this, SIGNAL(SignalSetColor(QColor)),
QTEMessages, SLOT(setTextColor(QColor)));
connect(QTEMessages, SIGNAL(textChanged()),
this, SLOT(SlotTextChanged()));
}
示例6: QRadioButton
/** Add a radio button to the plot options
*
* @param text :: text on the radio button
* @param tooltip :: tooltip
* @param bIntegrated :: flag to indicate that the dimension is integrated.
*/
void LinePlotOptions::addPlotRadioButton(const std::string &text,
const std::string &tooltip,
const bool bIntegrated) {
QRadioButton *rad;
rad = new QRadioButton(ui.widgetPlotAxis);
rad->setText(QString::fromStdString(text));
rad->setToolTip(QString::fromStdString(tooltip));
rad->setEnabled(!bIntegrated);
// Insert it one before the horizontal spacer.
QBoxLayout *layout = qobject_cast<QBoxLayout *>(ui.widgetPlotAxis->layout());
layout->insertWidget(layout->count() - 1, rad);
m_radPlots.push_back(rad);
QObject::connect(rad, SIGNAL(toggled(bool)), this, SLOT(radPlot_changed()));
}
示例7: KDialog
// new groups
void KNGroupDialog::slotUser2()
{
QDate lastDate = a_ccount->lastNewFetch();
KDialog *dlg = new KDialog( this );
dlg->setCaption( i18n("New Groups") );
dlg->setButtons( Ok | Cancel );
QGroupBox *btnGrp = new QGroupBox( i18n("Check for New Groups"), dlg );
dlg->setMainWidget(btnGrp);
QGridLayout *topL = new QGridLayout( btnGrp );
QRadioButton *takeLast = new QRadioButton( i18n("Created since last check:"), btnGrp );
topL->addWidget(takeLast, 0, 0, 1, 2 );
QLabel *l = new QLabel(KGlobal::locale()->formatDate(lastDate, KLocale::LongDate),btnGrp);
topL->addWidget(l, 1, 1, Qt::AlignLeft);
connect(takeLast, SIGNAL(toggled(bool)), l, SLOT(setEnabled(bool)));
QRadioButton *takeCustom = new QRadioButton( i18n("Created since this date:"), btnGrp );
topL->addWidget(takeCustom, 2, 0, 1, 2 );
dateSel = new KDatePicker( lastDate, btnGrp );
dateSel->setMinimumSize(dateSel->sizeHint());
topL->addWidget(dateSel, 3, 1, Qt::AlignLeft);
connect(takeCustom, SIGNAL(toggled(bool)), this, SLOT(slotDatePickerEnabled(bool)));
takeLast->setChecked(true);
dateSel->setEnabled(false);
topL->addItem( new QSpacerItem(30, 0 ), 0, 0 );
if (dlg->exec()) {
if (takeCustom->isChecked())
lastDate = dateSel->date();
a_ccount->setLastNewFetch(QDate::currentDate());
leftLabel->setText(i18n("Checking for new groups..."));
enableButton(User1,false);
enableButton(User2,false);
filterEdit->clear();
subCB->setChecked(false);
newCB->setChecked(true);
emit(checkNew(a_ccount,lastDate));
incrementalFilter=false;
slotRefilter();
}
delete dlg;
}
示例8: QDialog
TransparencyDialog::TransparencyDialog( QWidget * parent, ViewerRendererWidget * vrw )
: QDialog( parent )
, m_renderer( vrw )
{
DP_ASSERT( m_renderer );
setWindowTitle( "Transparency Settings" );
setWindowFlags( windowFlags() & ~Qt::WindowContextHelpButtonHint );
m_restoreTransparencyMode = m_renderer->getTransparencyMode();
QRadioButton * noneButton = new QRadioButton( "None" );
noneButton->setChecked( m_restoreTransparencyMode == dp::sg::renderer::rix::gl::TransparencyMode::NONE );
QRadioButton * sortedBlendedButton = new QRadioButton( "Sorted Blended" );
sortedBlendedButton->setChecked( m_restoreTransparencyMode == dp::sg::renderer::rix::gl::TransparencyMode::SORTED_BLENDED );
QRadioButton * orderIndependentClosestListButton = new QRadioButton( "Order Independent Closest List" );
orderIndependentClosestListButton->setChecked( m_restoreTransparencyMode == dp::sg::renderer::rix::gl::TransparencyMode::ORDER_INDEPENDENT_CLOSEST_LIST );
QRadioButton * orderIndependentAllButton = new QRadioButton( "Order Independent All" );
orderIndependentAllButton->setChecked( m_restoreTransparencyMode == dp::sg::renderer::rix::gl::TransparencyMode::ORDER_INDEPENDENT_ALL );
QButtonGroup * buttonGroup = new QButtonGroup();
buttonGroup->addButton( noneButton, static_cast<int>(dp::sg::renderer::rix::gl::TransparencyMode::NONE) );
buttonGroup->addButton( sortedBlendedButton, static_cast<int>(dp::sg::renderer::rix::gl::TransparencyMode::SORTED_BLENDED) );
buttonGroup->addButton( orderIndependentClosestListButton, static_cast<int>(dp::sg::renderer::rix::gl::TransparencyMode::ORDER_INDEPENDENT_CLOSEST_LIST) );
buttonGroup->addButton( orderIndependentAllButton, static_cast<int>(dp::sg::renderer::rix::gl::TransparencyMode::ORDER_INDEPENDENT_ALL) );
connect( buttonGroup, SIGNAL(buttonClicked(int)), this, SLOT(buttonClicked(int)) );
m_restoreLayers = m_renderer->getOITDepth();
m_layersBox = new QSpinBox();
m_layersBox->setMinimum( 1 );
m_layersBox->setValue( m_restoreLayers );
m_layersBox->setEnabled( ( m_restoreTransparencyMode == dp::sg::renderer::rix::gl::TransparencyMode::ORDER_INDEPENDENT_CLOSEST_ARRAY )
|| ( m_restoreTransparencyMode == dp::sg::renderer::rix::gl::TransparencyMode::ORDER_INDEPENDENT_CLOSEST_LIST ) );
connect( m_layersBox, SIGNAL(valueChanged(int)), this, SLOT(layersChanged(int)) );
QFormLayout * layersLayout = new QFormLayout;
layersLayout->addRow( "Transparency Layers", m_layersBox );
QFrame * separatorLine = new QFrame;
separatorLine->setFrameShape( QFrame::HLine );
separatorLine->setFrameShadow( QFrame::Sunken );
QDialogButtonBox * dbb = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel );
dbb->button( QDialogButtonBox::Ok )->setDefault ( true );
connect( dbb, SIGNAL(accepted()), this, SLOT(accept()) );
connect( dbb, SIGNAL(rejected()), this, SLOT(reject()) );
QVBoxLayout * vLayout = new QVBoxLayout();
vLayout->addWidget( noneButton );
vLayout->addWidget( sortedBlendedButton );
vLayout->addWidget( orderIndependentClosestListButton );
vLayout->addLayout( layersLayout );
vLayout->addWidget( orderIndependentAllButton );
vLayout->addWidget( separatorLine );
vLayout->addWidget( dbb );
setLayout( vLayout );
adjustSize();
setMinimumSize( size() );
setMaximumSize( size() );
}
示例9: ChangeLanguage
void MainWindow::ChangeLanguage()
{
std::clog<<"MainWindow::ChangeLanguage()"<<std::endl;
QList<QRadioButton*> list = ui->groupBox->findChildren<QRadioButton*>();
for(int i=0;i<list.size();i++)
{
QRadioButton* rb = list.at(i);
if(rb->isChecked())
{
lang->ChangeLanguage(rb->property(("lang_file")).toString()); // lang_file is dynamic property
break;
}
}
ui->retranslateUi(this);
}
示例10: egx_radiobutton_create_
egx_wnd_t egx_radiobutton_create_(int res_id,char *name,egx_uint32_t style,int x,int y,int width,int height,egx_wnd_t parent,egx_wnd_t radiogroup)
{
QRadioButton *button = new QRadioButton((QWidget*)(parent));
button->setText(QString::fromLocal8Bit(name));
if(x == 0 || y == 0){
button->resize(width,height);
}else{
button->setGeometry(x,y,width,height);
}
QButtonGroup *_radiogroup = (QButtonGroup*)radiogroup;
if(_radiogroup){
_radiogroup->addButton(button);
}
return HWND_TO_GUIWND(button);
}
示例11: if
void GlyphEditor::setPrimitives(int p){
primitives = p;
if (p==0){
QRadioButton* prb = findChild<QRadioButton*>("points");
prb->setChecked(true);
if (data->surfset) data->surfset->vectors = false;
if (data->surfsetr) data->surfsetr->vectors = false;
} else if (p==1){
QRadioButton* vrb = findChild<QRadioButton*>("vectors");
vrb->setChecked(true);
if (data->surfset) data->surfset->vectors = true;
if (data->surfsetr) data->surfsetr->vectors = true;
}
update();
}
示例12: LOG_QMSG
//------------------------------------------------------------------------------------------------
// To create the group of radiobuttons for cell constituent selection.
// This uses information about active constituents fetched from the DLL.
// Need to distinguish field constituent from cell constituent, because for the cell we are
// interested in CFSE, volume, O2byvol in addition to the dissolved constituents:
// oxygen, glucose, drugA, drugB, metabolites...
//------------------------------------------------------------------------------------------------
void Field::setCellConstituentButtons(QGroupBox *gbox, QButtonGroup *bg, QVBoxLayout **vbox, QList<QRadioButton *> *rb_list, QString tag)
{
int ivar;
QString name, str, ivar_str;
QRadioButton *rb;
LOG_QMSG("setCellConstituentButtons: " + tag);
if (rb_list->length() != 0) {
LOG_MSG("rb_list not NULL, delete it");
for (ivar=0; ivar<rb_list->length(); ivar++) {
rb = (*rb_list)[ivar];
bg->removeButton(rb);
delete rb;
}
rb_list->clear();
}
if (!*vbox) {
LOG_MSG("vbox = NULL, create it");
*vbox = new QVBoxLayout;
gbox->setLayout(*vbox);
}
name = "rb_cell_constituent_"+tag;
LOG_QMSG(name);
sprintf(msg,"rb_list: %p vbox: %p bg: %p nvars_used: %d",rb_list,*vbox,bg,Global::nvars_used);
LOG_MSG(msg);
for (ivar=0; ivar<Global::nvars_used; ivar++) {
ivar_str = QString::number(ivar);
str = Global::var_string[ivar];
rb = new QRadioButton;
rb->setText(str);
rb->setObjectName(name+ivar_str);
(*vbox)->addWidget(rb);
rb->setEnabled(true);
bg->addButton(rb,ivar);
rb_list->append(rb);
// LOG_QMSG(rb->objectName());
}
LOG_MSG("added buttons");
if (tag.contains("FACS")) {
(*rb_list)[0]->setChecked(true); // CFSE
} else {
(*rb_list)[1]->setChecked(true); // Oxygen
}
QRect rect = gbox->geometry();
rect.setHeight(25*Global::nvars_used);
gbox->setGeometry(rect);
gbox->show();
}
示例13: while
void KSaneDeviceDialog::updateDevicesList()
{
while (!m_btnGroup->buttons().isEmpty()) {
delete m_btnGroup->buttons().takeFirst();
}
const QList<KSaneWidget::DeviceInfo> list = m_findDevThread->devicesList();
if (list.isEmpty()) {
m_btnBox->setTitle(i18n("Sorry. No devices found."));
m_btnBox->layout()->itemAt(0)->widget()->show(); // explanation
m_btnBox->layout()->itemAt(1)->widget()->hide(); // scroll area
enableButton(KDialog::User1, true);
return;
}
delete m_btnLayout;
m_btnLayout = new QVBoxLayout;
m_btnContainer->setLayout(m_btnLayout);
m_btnBox->setTitle(i18n("Found devices:"));
m_btnBox->layout()->itemAt(0)->widget()->hide(); // explanation
m_btnBox->layout()->itemAt(1)->widget()->show(); // scroll area
for (int i=0; i< list.size(); i++) {
QRadioButton *b = new QRadioButton(this);
b->setObjectName(list[i].name);
b->setToolTip(list[i].name);
b->setText(QString("%1 : %2\n%3")
.arg(list[i].vendor)
.arg(list[i].model)
.arg(list[i].name));
m_btnLayout->addWidget(b);
m_btnGroup->addButton(b);
connect(b, SIGNAL(clicked(bool)), this, SLOT(setAvailable(bool)));
if((i==0) || (list[i].name == m_selectedDevice)) {
b->setChecked(true);
setAvailable(true);
}
}
m_btnLayout->addStretch();
if(list.size() == 1) {
button(KDialog::Ok)->animateClick();
}
enableButton(KDialog::User1, true);
}
示例14: QMainWindow
TrainerGui::TrainerGui(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::TrainerGui)
{
ui->setupUi(this);
ui_label1 = qFindChild<ClickLabel*>(this, "img1Label");
ui_label2 = qFindChild<ClickLabel*>(this, "img2Label");
// defaults
QRadioButton *posRadio = qFindChild<QRadioButton*>(this, "positiveRadio");
posRadio->setChecked(true);
m_trainingType = m_posTrainingType;
m_trainingFile = NULL;
m_defaultImgWidth = 640;
}
示例15: QRadioButton
void MultipleChoiceWidget::addButton() {
QSize newSize = this->size();
QRadioButton * button = new QRadioButton(tr("Insert Text: New"), this);
//QFont *font = new QFont("Arial", 100);
//button->setFont(*font);
correctButtonSize(button);
questions->append(button);
box->addButton(button);
gridLayoutButtonGroup->addWidget(button);
if (button->width() > this->width())
newSize.setWidth(button->width());
newSize.setHeight(questions->size() * button->height());
this->resize(newSize);
button->show();
this->update();
}