当前位置: 首页>>代码示例>>C++>>正文


C++ QCheckBox::setCheckState方法代码示例

本文整理汇总了C++中QCheckBox::setCheckState方法的典型用法代码示例。如果您正苦于以下问题:C++ QCheckBox::setCheckState方法的具体用法?C++ QCheckBox::setCheckState怎么用?C++ QCheckBox::setCheckState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QCheckBox的用法示例。


在下文中一共展示了QCheckBox::setCheckState方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AddBooleans

void ParamWidget::AddBooleans(const std::vector<BoolItem>& to_add,
    DisplayHint display_hint) {
  if (display_hint != kCheckBox) {
    throw std::invalid_argument("Invalid display hint");
  }

  QWidget* row_widget = new QWidget(this);
  QHBoxLayout* hbox = new QHBoxLayout(row_widget);
  for (const BoolItem& item : to_add) {
    ExpectNameNotFound(item.name);

    QCheckBox* checkbox =
      new QCheckBox(item.name, this);

    if (item.initially_checked) {
      checkbox->setCheckState(Qt::Checked);
    } else {
     checkbox->setCheckState(Qt::Unchecked);
    }
    checkbox->setProperty("param_widget_type", kParamBool);

    widgets_[item.name] = checkbox;
    hbox->addWidget(checkbox);

    connect(checkbox, &QCheckBox::stateChanged,
        [this, item](int val) { emit ParamChanged(item.name); });
  }

  layout_->addWidget(row_widget);
}
开发者ID:ashuang,项目名称:sceneview,代码行数:30,代码来源:param_widget.cpp

示例2: initView

void IndicatorDataView::initView(const QString& indicator)
{
  if(!mPainter->mIndicator) return;

  mIndicator = indicator;

  // Delete old entries

  // Insert new entries
  QStringList var;
  //mPainter->mData->getVariableNames(var);
  QSet<QString> varList;
  mPainter->mIndicator->getVariableNames(&varList);
  var = varList.values();
  //qDebug() << "IndicatorDataView::initView()" << var << varList.size();

  // Sort the variable list, but place the bardata as block in front
  var.removeAt(var.indexOf("OPEN"));
  var.removeAt(var.indexOf("HIGH"));
  var.removeAt(var.indexOf("LOW"));
  var.removeAt(var.indexOf("CLOSE"));
  var.removeAt(var.indexOf("VOLUME"));
  var.removeAt(var.indexOf("OPINT"));
  var.sort();
  var.prepend("OPINT");
  var.prepend("VOLUME");
  var.prepend("CLOSE");
  var.prepend("LOW");
  var.prepend("HIGH");
  var.prepend("OPEN");
  var.prepend("Date"); // Should not be a variable but is also interesting

  // And now insert entries
  int row = 0;
  QString name;
  QCheckBox* cb;

  mFilterView.setColumnCount(1);
  mFilterView.setRowCount(var.size());

  // Restore saved settings, if some
  QString filterPath;
  filterPath = mRcFile->getPath("FiluHome");
  filterPath.append("IndicatorFilterSettings/");
  SettingsFile sfile(filterPath + mIndicator);

  foreach(name, var)
  {
    cb = new QCheckBox(name);
    if(sfile.getBL(name))
    {
      cb->setCheckState(Qt::Checked);
    }
    else
    {
      cb->setCheckState(Qt::Unchecked);
    }
    connect(cb, SIGNAL(stateChanged(int)), this, SLOT(filterChanged(int)));
    mFilterView.setCellWidget(row++, 0, cb);
  }
开发者ID:loh-tar,项目名称:filu,代码行数:60,代码来源:IndicatorDataView.cpp

示例3: setupViewCheckboxes

void TaskProjGroup::setupViewCheckboxes(bool addConnections)
{
    if ( multiView == NULL ) {
        return;
    }

    // There must be a better way to construct this list...
    QCheckBox * viewCheckboxes[] = { ui->chkView0,
                                     ui->chkView1,
                                     ui->chkView2,
                                     ui->chkView3,
                                     ui->chkView4,
                                     ui->chkView5,
                                     ui->chkView6,
                                     ui->chkView7,
                                     ui->chkView8,
                                     ui->chkView9 };


    for (int i = 0; i < 10; ++i) {
        QCheckBox *box = viewCheckboxes[i];
        if (addConnections) {
            connect(box, SIGNAL(toggled(bool)), this, SLOT(viewToggled(bool)));
        }

        const char *viewStr = viewChkIndexToCStr(i);
        if ( viewStr != NULL && multiView->hasProjection(viewStr) ) {
            box->setCheckState(Qt::Checked);
        } else {
            box->setCheckState(Qt::Unchecked);
        }
    }
}
开发者ID:davidlni,项目名称:FreeCAD,代码行数:33,代码来源:TaskProjGroup.cpp

示例4: updateWidgetValue

void WidgetMOItem::updateWidgetValue(QWidget* curWidget, QVariant value)
{
    QComboBox* combo = dynamic_cast<QComboBox*>(curWidget);
    if(combo)
        combo->setEditText(value.toString());

    QSpinBox* spinBox = dynamic_cast<QSpinBox*>(curWidget);
    if(spinBox)
        spinBox->setValue(value.toInt());

    QScienceSpinBox* doubleSpinBox = dynamic_cast<QScienceSpinBox*>(curWidget);
    if(doubleSpinBox)
        doubleSpinBox->setValue(value.toDouble());

    QCheckBox* checkBox = dynamic_cast<QCheckBox*>(curWidget);
    if(checkBox)
    {
        if(value.toBool())
            checkBox->setCheckState(Qt::Checked);
        else
            checkBox->setCheckState(Qt::Unchecked);
    }

    QLineEdit* lineEdit = dynamic_cast<QLineEdit*>(curWidget);
    if(lineEdit)
        lineEdit->setText(value.toString());
}
开发者ID:OpenModelica,项目名称:OMOptim,代码行数:27,代码来源:WidgetMOItem.cpp

示例5: QListWidgetItem

void
WidgetVpzPropertyExpCond::refresh()
{
    // First, clear the current list content
    bool oldBlock = QListWidget::blockSignals(true);
    QListWidget::clear();
    QString dyn = mVpz->modelDynFromDoc(mModQuery);
    // TODO only way to see if it is an atomic model ??
    QDomNodeList conds = mVpz->condsListFromConds(mVpz->condsFromDoc());
    for (int i = 0; i < conds.length(); i++) {
        QDomNode cond = conds.at(i);
        QString condName = DomFunctions::attributeValue(cond, "name");
        QListWidgetItem* wi = new QListWidgetItem(this);
        QListWidget::addItem(wi);
        QCheckBox* cb = new QCheckBox(this);
        cb->setText(condName);
        if (mVpz->isAttachedCond(mModQuery, condName)) {
            cb->setCheckState(Qt::Checked);
        } else {
            cb->setCheckState(Qt::Unchecked);
        }
        QObject::connect(
          cb, SIGNAL(toggled(bool)), this, SLOT(onCheckboxToggle(bool)));
        QListWidget::setItemWidget(wi, cb);
    }
    QListWidget::blockSignals(oldBlock);
}
开发者ID:Chabrier,项目名称:vle,代码行数:27,代码来源:widgetvpzproperty.cpp

示例6: SetBool

void ParamWidget::SetBool(const QString& name, bool val) {
  QCheckBox* checkbox = dynamic_cast<QCheckBox*>(GetWidget(name));
  if (!checkbox) {
    throw std::invalid_argument("Invalid bool parameter " + name.toStdString());
  }
  if (val) {
    checkbox->setCheckState(Qt::Checked);
  } else {
    checkbox->setCheckState(Qt::Unchecked);
  }
}
开发者ID:ashuang,项目名称:sceneview,代码行数:11,代码来源:param_widget.cpp

示例7: buildFlagWidget

QWidget* ConfigDialog::buildFlagWidget(const ConfigurationValue *value) {
    
    QCheckBox *checkBox = new QCheckBox();

    if(value->GetScalar() == 0.0) checkBox->setCheckState(Qt::Checked);
    else checkBox->setCheckState(Qt::Unchecked);
    

    QObject::connect(checkBox, SIGNAL(stateChanged(int)), value, SLOT(SetBoolean(int)));
    QObject::connect(checkBox, SIGNAL(stateChanged(int)), this, SLOT(valueChanged()));
    
    return checkBox;
}
开发者ID:animesh-garg,项目名称:graspSoft,代码行数:13,代码来源:ConfigDialog.cpp

示例8: QWidget

// MODELVIEW PAGE //
ModelViewPage::ModelViewPage(QWidget* parent, QSettings* appSettings) :
    QWidget(parent),
    m_pAppSettings(appSettings)
{
    QLabel* backgroundColor = new QLabel("Window Background Color", this);
    ColorWidget* bgColorSelect = new ColorWidget(this);
    QCheckBox* dragEnabled = new QCheckBox("Tool Dragging Enabled", this);
    QCheckBox* previewEnabled = new QCheckBox("Tool Preview Enabled", this);

    QGroupBox* modelViewGroup = new QGroupBox();

    QGridLayout* gridLayout = new QGridLayout;
    gridLayout->addWidget(backgroundColor, 0, 0);
    gridLayout->addWidget(bgColorSelect, 0, 1);
    gridLayout->addWidget(dragEnabled, 2, 0);
    gridLayout->addWidget(previewEnabled, 3, 0);
    modelViewGroup->setLayout(gridLayout);

    QVBoxLayout* mainLayout = new QVBoxLayout;
    mainLayout->addWidget(modelViewGroup);
    mainLayout->addStretch(1);
    setLayout(mainLayout);

    // Populate the settings
    bgColorSelect->setColor(m_pAppSettings->value("GLModelWidget/backgroundColor",
                                                  QColor(161,161,161)).value<QColor>());
    if (m_pAppSettings->value("GLModelWidget/dragEnabled", true).toBool())
        dragEnabled->setCheckState(Qt::Checked);
    else
        dragEnabled->setCheckState(Qt::Unchecked);
    if (m_pAppSettings->value("GLModelWidget/previewEnabled", true).toBool())
        previewEnabled->setCheckState(Qt::Checked);
    else
        previewEnabled->setCheckState(Qt::Unchecked);


    // Backup original values
    m_backgroundColorOrig = bgColorSelect->color();
    m_dragEnabledOrig = dragEnabled->isChecked();
    m_previewEnabledOrig = previewEnabled->isChecked();

    // Hook up the signals
    QObject::connect(bgColorSelect, SIGNAL(colorChanged(QColor)),
                     this, SLOT(setBackgroundColor(QColor)));
    QObject::connect(dragEnabled, SIGNAL(stateChanged(int)),
                     this, SLOT(setDragEnabled(int)));
    QObject::connect(previewEnabled, SIGNAL(stateChanged(int)),
                     this, SLOT(setPreviewEnabled(int)));
}
开发者ID:Nvveen,项目名称:sproxel,代码行数:50,代码来源:PreferencesDialog.cpp

示例9: setEditorData

void DelegateInfoCheckBox::setEditorData(QWidget *editor, const QModelIndex &index) const
{
    if(index.column() == 0){
        return;
    }

    bool value = index.model()->data(index, Qt::DisplayRole).toBool();
    QCheckBox *checkBox = static_cast<QCheckBox*>(editor);

    if(value){
        checkBox->setCheckState(Qt::Checked);
    }else{
        checkBox->setCheckState(Qt::Unchecked);
    }
}
开发者ID:maluginp,项目名称:tsunami-optimus,代码行数:15,代码来源:delegateinfocheckbox.cpp

示例10: drv_checkbox

int drv_checkbox(int drvid, void *a0, void* a1, void* a2, void* a3, void* a4, void* a5, void* a6, void* a7, void* a8, void* a9)
{
    handle_head* head = (handle_head*)a0;
    QCheckBox *self = (QCheckBox*)head->native;
    switch (drvid) {
    case CHECKBOX_INIT: {
        drvNewObj(a0,new QCheckBox);
        break;
    }
    case CHECKBOX_SETCHECK: {
        self->setCheckState((Qt::CheckState)drvGetInt(a1));
        break;
    }
    case CHECKBOX_CHECK: {
        drvSetInt(a1,self->checkState());
        break;
    }
    case CHECKBOX_SETTRISTATE: {
        self->setTristate(drvGetBool(a1));
        break;
    }
    case CHECKBOX_ISTRISTATE: {
        drvSetBool(a1,self->isTristate());
        break;
    }
    case CHECKBOX_ONSTATECHANGED: {
        QObject::connect(self,SIGNAL(stateChanged(int)),drvNewSignal(self,a1,a2),SLOT(call(int)));
        break;
    }
    default:
        return 0;
    }
    return 1;
}
开发者ID:weigj,项目名称:loongide,代码行数:34,代码来源:cdrv.cpp

示例11: query

void core::DatabaseMapperDialog::fillTable(const QString &sqlTableName)
{
	if(!_db.isOpen()) _db.open();

	QString strQuery = "show columns from " + sqlTableName;

	QSqlQuery query(strQuery, _db);

	tblMapView->clear();

	tblMapView->setHorizontalHeaderLabels(QStringList()
										  << tr("Source columns")
										  << tr("Map to")
										  << tr("Field type")
										  << tr("Enabled"));
	while(query.next())
	{
		tblMapView->setItem(tblMapView->rowCount() - 1, 0, new QTableWidgetItem(query.value("Field").toString()));
		tblMapView->setItem(tblMapView->rowCount() - 1, 1, new QTableWidgetItem(tr("in")));

		QComboBox *cb = new QComboBox();
		cb->addItems(QStringList()
					 << tr("Input")
					 << tr("Target"));
		tblMapView->setCellWidget(tblMapView->rowCount() - 1, 2, cb);

		QCheckBox *tbw = new QCheckBox();
		tbw->setCheckState(Qt::Checked);
		tblMapView->setItem(tblMapView->rowCount() - 1, 3, new QTableWidgetItem());
		tblMapView->setCellWidget(tblMapView->rowCount() - 1, 3, tbw);
		tblMapView->item(tblMapView->rowCount() - 1, 3)->setTextAlignment(Qt::AlignLeft);

		tblMapView->insertRow(tblMapView->rowCount());
	}
}
开发者ID:VARPERTecnology,项目名称:INSYDE,代码行数:35,代码来源:databasemapperdialog.cpp

示例12: load

void TemplateOptionsPage::load(const SourceFileTemplate& fileTemplate, TemplateRenderer* renderer)
{
    d->entries.clear();

    QLayout* layout = new QVBoxLayout();
    QHash<QString, QList<SourceFileTemplate::ConfigOption> > options = fileTemplate.customOptions(renderer);
    QHash<QString, QList<SourceFileTemplate::ConfigOption> >::const_iterator it;

    for (it = options.constBegin(); it != options.constEnd(); ++it)
    {
        QGroupBox* box = new QGroupBox(this);
        box->setTitle(it.key());

        QFormLayout* formLayout = new QFormLayout;

        d->entries << it.value();
        foreach (const SourceFileTemplate::ConfigOption& entry, it.value())
        {
            QLabel* label = new QLabel(entry.label, box);
            QWidget* control = 0;
            const QString type = entry.type;
            if (type == "String")
            {
                control = new KLineEdit(entry.value.toString(), box);
            }
            else if (type == "Int")
            {
                KIntNumInput* input = new KIntNumInput(entry.value.toInt(), box);
                if (!entry.minValue.isEmpty())
                {
                    input->setMinimum(entry.minValue.toInt());
                }
                if (!entry.maxValue.isEmpty())
                {
                    input->setMaximum(entry.maxValue.toInt());
                }
                control = input;
            }
            else if (type == "Bool")
            {
                bool checked = (QString::compare(entry.value.toString(), "true", Qt::CaseInsensitive) == 0);
                QCheckBox* checkBox = new QCheckBox(entry.label, box);
                checkBox->setCheckState(checked ? Qt::Checked : Qt::Unchecked);
            }
            else
            {
                kDebug() << "Unrecognized option type" << entry.type;
            }
            if (control)
            {
                formLayout->addRow(label, control);
                d->controls.insert(entry.name, control);
            }
        }

        box->setLayout(formLayout);
        layout->addWidget(box);
    }
    setLayout(layout);
}
开发者ID:caidongyun,项目名称:kdevplatform,代码行数:60,代码来源:templateoptionspage.cpp

示例13: applyUserSettings

/**
 * Applies the stored lists of which fittings and logs have been selected/deselected by the user.
 */
void MuonAnalysisResultTableTab::applyUserSettings()
{
  // If we're just starting the tab for the first time (and there are no user choices),
  // then don't bother.
  if( m_savedLogsState.isEmpty() && m_unselectedFittings.isEmpty() )
    return;
  
  // If any of the logs have previously been selected by the user, select them again.
  for (int row = 0; row < m_uiForm.valueTable->rowCount(); ++row)
  {
    if(QTableWidgetItem * log = m_uiForm.valueTable->item(row,0))
    {
      if( m_savedLogsState.contains(log->text()) )
      {
        QCheckBox* logCheckBox = static_cast<QCheckBox*>(m_uiForm.valueTable->cellWidget(row,1));
        logCheckBox->setCheckState(m_savedLogsState[log->text()]);
      }
    }
  }

  // If any of the fittings have previously been deselected by the user, deselect them again.
  for (int row = 0; row < m_uiForm.fittingResultsTable->rowCount(); ++row)
  {
    QTableWidgetItem * temp = m_uiForm.fittingResultsTable->item(row,0);
    if( temp )
    {
      if( m_unselectedFittings.contains(temp->text()) )
      {
        QCheckBox* fittingChoice = static_cast<QCheckBox*>(m_uiForm.fittingResultsTable->cellWidget(row,1));
        fittingChoice->setChecked(false);
      }
    }
  }
}
开发者ID:Mantid-Test-Account,项目名称:mantid,代码行数:37,代码来源:MuonAnalysisResultTableTab.cpp

示例14: sceneChanged

void GroupSelWidget::sceneChanged()
{
    QSet<QString> groupSet = _scene->getAllGroups();
    if(groupSet == _prevGroupSet)
        return;
    _prevGroupSet = groupSet;

    QList<QString> groups = groupSet.toList();
    qSort(groups);

    for(int i = 0; i < (int)_checkBoxes.size(); ++i)
        delete _checkBoxes[i];
    _checkBoxes.clear();

    int childWidth = 0;
    for(int i = 0; i < (int)groups.size(); ++i) {
        QCheckBox *box =  new QCheckBox(groups[i], this);
        QFont font = box->font();
        font.setPointSize(14);
        box->setFont(font);
        box->setCheckState(_scene->isGroupVisible(groups[i]) ? Qt::Checked : Qt::Unchecked);
        new VisibilitySetter(box, _scene, groups[i]);
        layout()->addWidget(box);
        childWidth = max(childWidth, box->sizeHint().width());
        _checkBoxes.push_back(box);
    }

    setMinimumWidth(150);

    QWidget *scrollArea = parentWidget()->parentWidget()->parentWidget();
    scrollArea->setMinimumWidth(childWidth + 20);
}
开发者ID:F2X,项目名称:cornucopia-lib,代码行数:32,代码来源:GroupSelWidget.cpp

示例15: QGroupBox

//! [7]
QGroupBox *Window::createNonExclusiveGroup()
{
    QGroupBox *groupBox = new QGroupBox(tr("Non-Exclusive Checkboxes"));
    groupBox->setFlat(true);
//! [7]

//! [8]
    QCheckBox *checkBox1 = new QCheckBox(tr("&Checkbox 1"));
    QCheckBox *checkBox2 = new QCheckBox(tr("C&heckbox 2"));
    checkBox2->setChecked(true);
    QCheckBox *tristateBox = new QCheckBox(tr("Tri-&state button"));
    tristateBox->setTristate(true);
//! [8]
    tristateBox->setCheckState(Qt::PartiallyChecked);

//! [9]
    QVBoxLayout *vbox = new QVBoxLayout;
    vbox->addWidget(checkBox1);
    vbox->addWidget(checkBox2);
    vbox->addWidget(tristateBox);
    vbox->addStretch(1);
    groupBox->setLayout(vbox);

    return groupBox;
}
开发者ID:Andreas665,项目名称:qt,代码行数:26,代码来源:window.cpp


注:本文中的QCheckBox::setCheckState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。