本文整理汇总了C++中QRadioButton::setChecked方法的典型用法代码示例。如果您正苦于以下问题:C++ QRadioButton::setChecked方法的具体用法?C++ QRadioButton::setChecked怎么用?C++ QRadioButton::setChecked使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRadioButton
的用法示例。
在下文中一共展示了QRadioButton::setChecked方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupNewHostDialog
void kiptablesgenerator::setupNewHostDialog()
{
newHostDialog = new KDialogBase(this, 0, true, i18n("Add Host"), KDialogBase::Ok | KDialogBase::Cancel);
QFrame *dialogArea = new QFrame(newHostDialog);
QGridLayout *layout = new QGridLayout(dialogArea, 5, 2);
QLabel *intro = new QLabel(i18n(
"<p>Here you can tell netfilter to allow all connections from a given host regardless of other rules, "
"or block all connections from a given host regardless of other rules.</p>"
"<p>You can specify a host either by IP address or MAC address.</p>"), dialogArea);
intro->show();
layout->addMultiCellWidget(intro, 0, 0, 0, 1);
QButtonGroup *whitelistOrBlacklist = new QButtonGroup(dialogArea);
whitelistOrBlacklist->hide();
QRadioButton *whitelist = new QRadioButton(i18n("&Allow"), dialogArea);
whitelist->setChecked(true);
whitelist->show();
layout->addWidget(whitelist, 1, 0);
namedWidgets["newHost_allow"] = whitelist;
whitelistOrBlacklist->insert(whitelist);
QRadioButton *blacklist = new QRadioButton(i18n("&Block"), dialogArea);
blacklist->setChecked(false);
blacklist->show();
layout->addWidget(blacklist, 1, 1);
whitelistOrBlacklist->insert(blacklist);
QButtonGroup *ipOrMAC = new QButtonGroup(dialogArea);
ipOrMAC->hide();
QRadioButton *useIP = new QRadioButton(i18n("&Use IP"), dialogArea);
useIP->setChecked(true);
useIP->show();
layout->addWidget(useIP, 2, 0);
namedWidgets["newHost_useIP"] = useIP;
ipOrMAC->insert(useIP);
QRadioButton *useMAC = new QRadioButton(i18n("U&se MAC"), dialogArea);
useMAC->show();
layout->addWidget(useMAC, 2, 1);
ipOrMAC->insert(useMAC);
QLabel *hostLabel = new QLabel(i18n("Host:"), dialogArea);
hostLabel->show();
layout->addMultiCellWidget(hostLabel, 3, 3, 0, 1);
KLineEdit *host = new KLineEdit(dialogArea);
host->show();
namedWidgets["newHost_address"] = host;
layout->addMultiCellWidget(host, 4, 4, 0, 1);
connect(newHostDialog, SIGNAL(okClicked()), this, SLOT(slotAddHost()));
dialogArea->show();
newHostDialog->setMainWidget(dialogArea);
}
示例2: 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() );
}
示例3: if
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 ( _default != NULL && (*iter).isDefault() )
{
radio->setChecked(true);
anyChecked = true;
}
else if (_default != NULL)
{
if ( callString.compare(_default->toString()) == 0 )
{
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;
}
示例4: showToolBarStylePopupMenu
void PdfViewer::showToolBarStylePopupMenu(const QPoint &pos)
{
QMenu *popupMenu = new QMenu(this);
popupMenu->setAttribute(Qt::WA_DeleteOnClose);
popupMenu->move(mapToGlobal(QPoint(0,0)) + pos);
QWidgetAction *iconOnlyAction = new QWidgetAction(popupMenu);
QRadioButton *iconOnlyRadio = new QRadioButton(tr("&Icons Only"), popupMenu);
iconOnlyAction->setDefaultWidget(iconOnlyRadio);
QWidgetAction *textOnlyAction = new QWidgetAction(popupMenu);
QRadioButton *textOnlyRadio = new QRadioButton(tr("&Text Only"), popupMenu);
textOnlyAction->setDefaultWidget(textOnlyRadio);
QWidgetAction *textBesideIconAction = new QWidgetAction(popupMenu);
QRadioButton *textBesideIconRadio = new QRadioButton(tr("Text &Alongside Icons"), popupMenu);
textBesideIconAction->setDefaultWidget(textBesideIconRadio);
QWidgetAction *textUnderIconAction = new QWidgetAction(popupMenu);
QRadioButton *textUnderIconRadio = new QRadioButton(tr("Text &Under Icons"), popupMenu);
textUnderIconAction->setDefaultWidget(textUnderIconRadio);
QButtonGroup *popupButtonGroup = new QButtonGroup(popupMenu);
popupButtonGroup->addButton(iconOnlyRadio);
popupButtonGroup->addButton(textOnlyRadio);
popupButtonGroup->addButton(textBesideIconRadio);
popupButtonGroup->addButton(textUnderIconRadio);
popupButtonGroup->setId(iconOnlyRadio, 0);
popupButtonGroup->setId(textOnlyRadio, 1);
popupButtonGroup->setId(textBesideIconRadio, 2);
popupButtonGroup->setId(textUnderIconRadio, 3);
connect(popupButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(slotChangeToolBarStyle(int)));
popupMenu->addAction(iconOnlyAction);
popupMenu->addAction(textOnlyAction);
popupMenu->addAction(textBesideIconAction);
popupMenu->addAction(textUnderIconAction);
popupMenu->setContentsMargins(5, 0, 5, 0);
QSettings settings;
settings.beginGroup("MainWindow");
const int toolBarStyleNumber = settings.value("ToolBarStyle", 0).toInt();
switch (toolBarStyleNumber)
{
case 0: iconOnlyRadio->setChecked(true); break;
case 1: textOnlyRadio->setChecked(true); break;
case 2: textBesideIconRadio->setChecked(true); break;
case 3: textUnderIconRadio->setChecked(true); break;
}
settings.endGroup();
popupMenu->show();
// make sure that the popupMenu stays completely inside the screen (must be done after popupMenu->show() in order to have the correct width)
const int desktopWidth = QApplication::desktop()->availableGeometry(this).width();
if (popupMenu->x() + popupMenu->width() > desktopWidth)
popupMenu->move(desktopWidth - popupMenu->width(), popupMenu->y());
}
示例5: updateAddresses
void SettingsWidget::updateAddresses(const Protos::Common::Interface& interfaceMess, QWidget* container)
{
QVBoxLayout* layout = container->findChild<QVBoxLayout*>();
if (!layout)
{
layout = new QVBoxLayout(container);
QMargins margins = layout->contentsMargins();
margins.setTop(3);
layout->setContentsMargins(margins);
}
QList<QRadioButton*> addressesNotUpdated = container->findChildren<QRadioButton*>();
for (int i = 0; i < interfaceMess.address_size(); i++)
{
const QString& addresseName = Common::ProtoHelper::getStr(interfaceMess.address(i), &Protos::Common::Interface::Address::address);
for (QListIterator<QRadioButton*> j(container->findChildren<QRadioButton*>()); j.hasNext();)
{
QRadioButton* addressButton = j.next();
if (addressButton->text() == addresseName)
{
addressesNotUpdated.removeOne(addressButton);
if (interfaceMess.address(i).listened())
addressButton->setChecked(true);
goto nextAddress;
}
}
{
// Address not found -> add a new one.
QRadioButton* newAddressButton = new QRadioButton(addresseName, container);
this->ui->grpAddressesToListenTo->addButton(newAddressButton);
if (interfaceMess.address(i).listened())
newAddressButton->setChecked(true);
layout->addWidget(newAddressButton);
}
nextAddress:
;
}
// Remove the non-existant addresses.
for (QListIterator<QRadioButton*> i(container->findChildren<QRadioButton*>()); i.hasNext();)
{
QRadioButton* current = i.next();
if (addressesNotUpdated.contains(current))
{
layout->removeWidget(current);
this->ui->grpAddressesToListenTo->removeButton(current);
delete current;
}
}
}
示例6: keyPressEvent
void GrpRadioButton::keyPressEvent(QKeyEvent *e)
{
switch (e->key()){
case Key_Down:{
QRadioButton *first = NULL;
QRadioButton *next = NULL;
QObjectList *l = parentWidget()->queryList("QRadioButton");
QObjectListIt it(*l);
QObject *obj;
while ((obj=it.current()) != NULL){
if (first == NULL)
first = static_cast<QRadioButton*>(obj);
if (obj == this){
++it;
if ((obj = it.current()) == NULL){
next = first;
}else{
next = static_cast<QRadioButton*>(obj);
}
break;
}
++it;
}
delete l;
if (next){
next->setFocus();
next->setChecked(true);
}
return;
}
case Key_Up:{
QRadioButton *prev = NULL;
QObjectList *l = parentWidget()->queryList("QRadioButton");
QObjectListIt it(*l);
QObject *obj;
while ((obj=it.current()) != NULL){
if ((obj == this) && prev)
break;
prev = static_cast<QRadioButton*>(obj);
++it;
}
delete l;
if (prev){
prev->setFocus();
prev->setChecked(true);
}
return;
}
}
QRadioButton::keyPressEvent(e);
}
示例7: setPrimitives
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();
}
示例8: addRadioButton
// Create new radio button
QtWidgetObject* AtenTreeGuiDialog::addRadioButton(TreeGuiWidget* widget, TreeGuiWidget* groupWidget, QString name, QString label, int id)
{
// Cast QObject in groupWidget into QButtonGroup
QtWidgetObject* wo = groupWidget->qtWidgetObject();
if (wo == NULL)
{
printf("Internal Error: Can't add button to radiogroup widget since supplied widget doesn't have an associated QtWidgetObject.\n");
return NULL;
}
QButtonGroup *group = static_cast<QButtonGroup*>(wo->qObject());
if (!group)
{
printf("Internal Error: Couldn't cast QObject into QButtonGroup.\n");
return NULL;
}
// Create new QtWidgetObject for page
QRadioButton *radio = new QRadioButton(label, this);
group->addButton(radio, id);
QtWidgetObject* qtwo = widgetObjects_.add();
qtwo->set(widget, radio);
radio->setEnabled(widget->enabled());
radio->setVisible(widget->visible());
radio->setChecked(widget->valueI() == 1);
radio->setMinimumHeight(WIDGETHEIGHT);
radio->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
// Connect signal to master slot
QObject::connect(radio, SIGNAL(clicked(bool)), this, SLOT(radioButtonWidget_clicked(bool)));
return qtwo;
}
示例9: PropertySpecialWidget
IsotropicElasticityPropertyWidget::IsotropicElasticityPropertyWidget(QWidget * parent) :
PropertySpecialWidget(parent)
{
buttonGroup_ = new QButtonGroup(this);
QVBoxLayout *vbox = new QVBoxLayout(this);
QRadioButton * rb;
rb = new QRadioButton("Calculated from Young's Modulus and Poisson Ratio", this);
vbox->addWidget(rb);
buttonGroup_->addButton(rb, 0);
rb->setChecked(true);
rb = new QRadioButton("Calculated from Young's Modulus and Shear Modulus", this);
vbox->addWidget(rb);
buttonGroup_->addButton(rb, 1);
rb = new QRadioButton("Calculated from Poisson Ratio and Shear Modulus", this);
vbox->addWidget(rb);
buttonGroup_->addButton(rb, 2);
vbox->addStretch(1);
setLayout(vbox);
connect(buttonGroup_, SIGNAL(buttonClicked(int)),
this, SLOT(modeChanged(int)));
}
示例10: addRadioButton
void MDRadioButtonGroup::addRadioButton(const QString &name, const QString &value)
{
QRadioButton *radio = new QRadioButton(name, this);
radio->setChecked(value == selected);
radiobuttons.insert(radio, value);
this->layout()->addWidget(radio);
}
示例11: setupIncomingPage
void kiptablesgenerator::setupIncomingPage()
{
incomingPage = new QFrame(this);
QGridLayout *layout = new QGridLayout(incomingPage, 2, 2);
QLabel *intro = new QLabel(i18n(
"<p>Do you want to filter incoming data? (recommended)</p>"
"<p>This will allow you to control other computers access to "
"your computer.</p>"), incomingPage);
intro->show();
layout->addMultiCellWidget(intro, 0, 0, 0, 1);
QButtonGroup *optYesNo = new QButtonGroup(incomingPage);
namedWidgets["incomingYesNo"] = optYesNo;
optYesNo->hide();
QRadioButton *optYes = new QRadioButton(i18n("&Yes"), incomingPage);
optYes->setChecked(true);
optYes->setName("yes");
optYes->show();
layout->addWidget(optYes, 1, 0);
optYesNo->insert(optYes);
QRadioButton *optNo = new QRadioButton(i18n("N&o"), incomingPage);
optNo->setName("no");
optNo->show();
layout->addWidget(optNo, 1, 1);
optYesNo->insert(optNo);
incomingPage->show();
this->addPage(incomingPage, i18n("Incoming Data"));
}
示例12: QDialog
ListInputDialog::ListInputDialog(QWidget *parent, const QString &title,
const QString &labelText, const QStringList &list,
int current, Qt::WFlags f) :
QDialog(parent, f),
m_strings(list)
{
setWindowTitle(title);
QVBoxLayout *vbox = new QVBoxLayout(this);
QLabel *label = new QLabel(labelText, this);
vbox->addWidget(label);
vbox->addStretch(1);
int count = 0;
for (QStringList::const_iterator i = list.begin(); i != list.end(); ++i) {
QRadioButton *radio = new QRadioButton(*i);
if (current == count++) radio->setChecked(true);
m_radioButtons.push_back(radio);
vbox->addWidget(radio);
}
vbox->addStretch(1);
m_footnote = new QLabel;
vbox->addWidget(m_footnote);
m_footnote->hide();
QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok |
QDialogButtonBox::Cancel);
vbox->addWidget(bb);
connect(bb, SIGNAL(accepted()), this, SLOT(accept()));
connect(bb, SIGNAL(rejected()), this, SLOT(reject()));
}
示例13: setupNextError
void QgsGeometryCheckerFixDialog::setupNextError()
{
mProgressBar->setValue( mProgressBar->maximum() - mErrors.size() );
mNextBtn->setVisible( false );
mFixBtn->setVisible( true );
mFixBtn->setFocus();
mSkipBtn->setVisible( true );
mStatusLabel->setText( "" );
mResolutionsBox->setEnabled( true );
QgsGeometryCheckError* error = mErrors.first();
emit currentErrorChanged( error );
mResolutionsBox->setTitle( tr( "Select how to fix error \"%1\":" ).arg( error->description() ) );
delete mRadioGroup;
mRadioGroup = new QButtonGroup( this );
delete mResolutionsBox->layout();
qDeleteAll( mResolutionsBox->children() );
mResolutionsBox->setLayout( new QVBoxLayout() );
mResolutionsBox->layout()->setContentsMargins( 0, 0, 0, 4 );
int id = 0;
int checkedid = QSettings().value( QgsGeometryCheckerResultTab::sSettingsGroup + error->check()->errorName(), QVariant::fromValue<int>( 0 ) ).toInt();
foreach ( const QString& method, error->check()->getResolutionMethods() )
{
QRadioButton* radio = new QRadioButton( method );
radio->setChecked( checkedid == id );
mResolutionsBox->layout()->addWidget( radio );
mRadioGroup->addButton( radio, id++ );
}
adjustSize();
}
示例14: QVBoxLayout
ServiceChooser::ServiceChooser(const QByteArray &service,
const LocalizedString &title,
const QByteArray ¤tService,
ExtensionInfoList &services,
QWidget *parent) :
QGroupBox(title, parent), m_layout(new QVBoxLayout(this)), m_service(service), m_currentService(currentService)
{
foreach (const ExtensionInfo &service, services) {
const QMetaObject *meta = service.generator()->metaObject();
QByteArray name = meta->className();
const char *desc = MetaObjectBuilder::info(meta, "SettingsDescription");
if (!desc || !*desc)
desc = name.constData();
QRadioButton *button = new QRadioButton(QCoreApplication::translate("ContactList", desc), this);
button->setObjectName(QString::fromLatin1(name));
button->setChecked(name == m_currentService);
connect(button, SIGNAL(toggled(bool)), SLOT(onButtonToggled(bool)));
m_buttons.insert(name, button);
m_infos.insert(name, service);
m_layout->addWidget(button);
}
connect(ServiceManager::instance(),
SIGNAL(serviceChanged(QByteArray,QObject*,QObject*)),
SLOT(onServiceChanged(QByteArray,QObject*,QObject*)));
}
示例15: populateImageEncodings
void QgsSourceSelectDialog::populateImageEncodings( const QStringList& availableEncodings )
{
QLayoutItem* item;
while (( item = gbImageEncoding->layout()->takeAt( 0 ) ) != nullptr )
{
delete item->widget();
delete item;
}
bool first = true;
QList<QByteArray> supportedFormats = QImageReader::supportedImageFormats();
foreach ( const QString& encoding, availableEncodings )
{
bool supported = false;
foreach ( const QByteArray& fmt, supportedFormats )
{
if ( encoding.startsWith( fmt, Qt::CaseInsensitive ) )
{
supported = true;
}
}
if ( !supported )
{
continue;
}
QRadioButton* button = new QRadioButton( encoding, this );
button->setChecked( first );
gbImageEncoding->layout()->addWidget( button );
mImageEncodingGroup->addButton( button );
first = false;
}