本文整理汇总了C++中QStandardItem::checkState方法的典型用法代码示例。如果您正苦于以下问题:C++ QStandardItem::checkState方法的具体用法?C++ QStandardItem::checkState怎么用?C++ QStandardItem::checkState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStandardItem
的用法示例。
在下文中一共展示了QStandardItem::checkState方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSelectedTypes
void VegetationWidget::getSelectedTypes(std::vector<std::string>& returnTypeList)
{
returnTypeList.clear();
QWidget* curWidget = _tabWidget->currentWidget();
if (curWidget == _treeListView)
{
QStandardItemModel* model = qobject_cast<QStandardItemModel*>(_treeListView->model());
for (int j = 0; j < model->rowCount(); ++j)
{
QStandardItem* item = model->item(j);
if (item->checkState() == Qt::Checked)
{
returnTypeList.push_back(chineseTextToUTF8String(item->text()));
}
}
}
else
{
QStandardItemModel* model = qobject_cast<QStandardItemModel*>(_grassListView->model());
for (int j = 0; j < model->rowCount(); ++j)
{
QStandardItem* item = model->item(j);
if (item->checkState() == Qt::Checked)
{
returnTypeList.push_back(chineseTextToUTF8String(item->text()));
}
}
}
}
示例2: clone
void tst_QStandardItem::clone()
{
QStandardItem item;
item.setText(QLatin1String("text"));
item.setToolTip(QLatin1String("toolTip"));
item.setStatusTip(QLatin1String("statusTip"));
item.setWhatsThis(QLatin1String("whatsThis"));
item.setSizeHint(QSize(64, 48));
item.setFont(QFont());
item.setTextAlignment(Qt::AlignLeft|Qt::AlignVCenter);
item.setBackground(QColor(Qt::blue));
item.setForeground(QColor(Qt::green));
item.setCheckState(Qt::PartiallyChecked);
item.setAccessibleText(QLatin1String("accessibleText"));
item.setAccessibleDescription(QLatin1String("accessibleDescription"));
item.setFlags(Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);
QStandardItem *clone = item.clone();
QCOMPARE(clone->text(), item.text());
QCOMPARE(clone->toolTip(), item.toolTip());
QCOMPARE(clone->statusTip(), item.statusTip());
QCOMPARE(clone->whatsThis(), item.whatsThis());
QCOMPARE(clone->sizeHint(), item.sizeHint());
QCOMPARE(clone->font(), item.font());
QCOMPARE(clone->textAlignment(), item.textAlignment());
QCOMPARE(clone->background(), item.background());
QCOMPARE(clone->foreground(), item.foreground());
QCOMPARE(clone->checkState(), item.checkState());
QCOMPARE(clone->accessibleText(), item.accessibleText());
QCOMPARE(clone->accessibleDescription(), item.accessibleDescription());
QCOMPARE(clone->flags(), item.flags());
QVERIFY(!(*clone < item));
delete clone;
}
示例3: onClicked
void FilterLvl::onClicked (QModelIndex idx)
{
if (!idx.isValid()) return;
QStandardItem * item = m_model->itemFromIndex(idx);
Q_ASSERT(item);
if (idx.column() == 1)
{
QString const & filter_item = m_model->data(m_model->index(idx.row(), 0, QModelIndex()), Qt::DisplayRole).toString();
QString const & mod = m_model->data(idx, Qt::DisplayRole).toString();
E_LevelMode const curr = stringToLvlMod(mod.toStdString().c_str()[0]);
size_t const i = (curr + 1) % e_max_lvlmod_enum_value;
E_LevelMode const new_mode = static_cast<E_LevelMode>(i);
m_model->setData(idx, QString(lvlModToString(new_mode)));
bool const checked = (item->checkState() == Qt::Checked);
setMode(filter_item, !checked, new_mode);
emitFilterChangedSignal();
}
else
{
QString const & filter_item = m_model->data(idx, Qt::DisplayRole).toString();
bool const orig_checked = (item->checkState() == Qt::Checked);
if (orig_checked)
append(filter_item);
else
remove(filter_item);
emitFilterChangedSignal();
}
}
示例4: saveWaveInfo
void PreferencesDialog::saveWaveInfo()
{
// Change focus to force save of any open editors..
ui->waveSearch->setFocus();
int toprows = waveModel->rowCount();
bool ok;
for (int i=0; i < toprows; i++) {
QStandardItem * topitem = waveModel->item(i,0);
if (!topitem) continue;
int rows = topitem->rowCount();
for (int j=0; j< rows; ++j) {
QStandardItem * item = topitem->child(j, 0);
if (!item) continue;
ChannelID id = item->data(Qt::UserRole).toUInt(&ok);
schema::Channel & chan = schema::channel[id];
if (chan.isNull()) continue;
chan.setEnabled(item->checkState() == Qt::Checked ? true : false);
chan.setFullname(item->text());
chan.setDefaultColor(QColor(topitem->child(j,1)->data(Qt::UserRole).toUInt()));
chan.setShowInOverview(topitem->child(j,2)->checkState() == Qt::Checked);
chan.setLowerThreshold(topitem->child(j,3)->text().toDouble());
chan.setUpperThreshold(topitem->child(j,4)->text().toDouble());
chan.setLabel(topitem->child(j,5)->text());
chan.setDescription(topitem->child(j,6)->text());
}
}
}
示例5: setData
bool FilterModel::setData(const QModelIndex & index,
const QVariant& value, int role)
{
bool res = QStandardItemModel::setData(index, value, role);
if (role == Qt::CheckStateRole)
{
if (!index.parent().isValid())
{
QStandardItem * item = itemFromIndex(index);
Qt::CheckState st = item->checkState();
if (st != Qt::PartiallyChecked)
{
for (int i = 0; i < item->rowCount(); i++)
{
item->child(i)->setCheckState(st);
}
}
}
emit filterChanged();
}
return res;
}
示例6: onItemClicked
void PluginChoooserWidget::onItemClicked(QModelIndex index)
{
QStandardItem *item = m_model->itemFromIndex(index);
if (item) {
item->setCheckState(item->checkState() == Qt::Unchecked ? Qt::Checked : Qt::Unchecked);
}
}
示例7: deleteTracking
void CSatelliteDlg::on_pushButton_5_clicked()
{
QStandardItemModel *model = (QStandardItemModel *)ui->listView->model();
for (int i = 0; i < model->rowCount(); i++)
{
QStandardItem *item = model->item(i);
sgp4.tleItem(i)->used = item->checkState() == Qt::Checked ? true : false;
}
if (sgp4.count() != 0)
{
if (msgBoxQuest(this, m_cSaveQuest) == QMessageBox::Yes)
{
if (!save(curSatelliteCatName))
{
return;
}
}
}
deleteTracking(MO_SATELLITE);
releaseHoldObject(MO_SATELLITE);
pcMainWnd->removeQuickInfo(MO_SATELLITE);
curSatelliteCatName.clear();
sgp4.removeAll();
fillList();
}
示例8: configAccepted
void Hdd::configAccepted()
{
KConfigGroup cg = config();
KConfigGroup cgGlobal = globalConfig();
QStandardItem *parentItem = m_hddModel.invisibleRootItem();
clear();
for (int i = 0; i < parentItem->rowCount(); ++i) {
QStandardItem *item = parentItem->child(i, 0);
if (item) {
QStandardItem *child = parentItem->child(i, 1);
if (child->text() != child->data().toString()) {
cgGlobal.writeEntry(item->data().toString(), child->text());
}
if (item->checkState() == Qt::Checked) {
appendSource(item->data().toString());
}
}
}
cg.writeEntry("uuids", sources());
uint interval = ui.intervalSpinBox->value();
cg.writeEntry("interval", interval);
emit configNeedsSaving();
}
示例9: apply
void NotifyOptionsWidget::apply()
{
Options::node(OPV_NOTIFICATIONS_POPUPTIMEOUT).setValue(ui.spbPopupTimeout->value());
for(QMap<QString, QStandardItem *>::const_iterator it=FTypeItems.constBegin(); it!=FTypeItems.constEnd(); ++it)
{
QStandardItem *typeNameItem = it.value();
ushort kinds = !it.key().isEmpty() ? FNotifications->typeNotificationKinds(it.key()) : 0;
for (int row=0; row<typeNameItem->rowCount(); row++)
{
QStandardItem *kindEnableItem = typeNameItem->child(row, COL_ENABLE);
if (kindEnableItem->checkState() == Qt::Checked)
kinds |= (ushort)kindEnableItem->data(MDR_KIND).toInt();
else
kinds &= ~((ushort)kindEnableItem->data(MDR_KIND).toInt());
}
if (!it.key().isEmpty())
FNotifications->setTypeNotificationKinds(it.key(),kinds);
else
FNotifications->setEnabledNotificationKinds(kinds);
}
emit childApply();
}
示例10: tree_clicked
void QToDoContent::tree_clicked(const QModelIndex &index)
{
int r = index.row();
QStandardItem *item = m_model->item(r,1);
QStandardItem *item2 = m_model->item(r,0);
QString data = QToDoData::ref().getData("127.0.0.1","fasp_yz","postgres","postgres");
qDebug()<<data;
m_edit->setText(data);
if ( item->checkState() == Qt::Checked )
{
qDebug()<<"Checked:";
QString data = m_model->data( m_model->index(r,0)).toString();
if ( m_type == ToDo )
{
QToDoData::ref().getToDo().removeAll(data);
}
qDebug()<<data;
m_taskList.append(data);
m_taskList.removeDuplicates();
}else
{
qDebug()<<"UnChecked";
}
}
示例11: OnDataChanged
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
void tCZoneModesModel::OnDataChanged()
{
bool modeChanged = false;
for ( int row=0; row < rowCount(); ++row )
{
QStandardItem* pItem = item( row );
if (pItem != 0)
{
bool ok;
int index = pItem->data( INDEX_ROLE ).toInt( &ok );
if ( ok )
{
tDigitalData state( tDataId( DATA_TYPE_SWITCH_STATE, index, DATA_ENGINE_CZONE_SELECTION ) );
Qt::CheckState checkState = Qt::Unchecked;
if ( state.Value() > 0 )
{
checkState = Qt::Checked;
}
Qt::CheckState oldCheckState = pItem->checkState();
pItem->setCheckState( checkState );
if ( oldCheckState != checkState )
{
modeChanged = true;
}
}
}
}
if ( modeChanged )
{
emit ModeChanged();
}
}
示例12: onOK
void QgsOSMExportDialog::onOK()
{
if ( !openDatabase() )
return;
QgsOSMDatabase::ExportType type;
if ( radPoints->isChecked() )
type = QgsOSMDatabase::Point;
else if ( radPolylines->isChecked() )
type = QgsOSMDatabase::Polyline;
else
type = QgsOSMDatabase::Polygon;
buttonBox->setEnabled( false );
QApplication::setOverrideCursor( Qt::WaitCursor );
QStringList tagKeys;
QStringList notNullTagKeys;
for ( int i = 0; i < mTagsModel->rowCount(); ++i )
{
QStandardItem* item = mTagsModel->item( i, 0 );
if ( item->checkState() == Qt::Checked )
tagKeys << item->text();
QStandardItem* item2 = mTagsModel->item( i, 2 );
if ( item2->checkState() == Qt::Checked )
notNullTagKeys << item->text();
}
bool res = mDatabase->exportSpatiaLite( type, editLayerName->text(), tagKeys, notNullTagKeys );
// load the layer into canvas if that was requested
if ( chkLoadWhenFinished->isChecked() )
{
QgsDataSourceUri uri;
uri.setDatabase( editDbFileName->text() );
uri.setDataSource( QString(), editLayerName->text(), "geometry" );
QgsVectorLayer* vlayer = new QgsVectorLayer( uri.uri(), editLayerName->text(), "spatialite" );
if ( vlayer->isValid() )
QgsMapLayerRegistry::instance()->addMapLayer( vlayer );
}
QApplication::restoreOverrideCursor();
buttonBox->setEnabled( true );
if ( res )
{
QMessageBox::information( this, tr( "OpenStreetMap export" ), tr( "Export has been successful." ) );
}
else
{
QMessageBox::critical( this, tr( "OpenStreetMap export" ), tr( "Failed to export OSM data:\n%1" ).arg( mDatabase->errorString() ) );
}
mDatabase->close();
}
示例13: cameraTree_recursiveCheck
// check QStandardItem and its decendants
void AbstractCameraManager::cameraTree_recursiveCheck(QStandardItem* parent, Qt::CheckState checked) {
qDebug() << "recursivecheck(" << checked << ") on " << parent->text();
for(int i=0; i<parent->rowCount(); ++i) {
QStandardItem* currItem = parent->child(i);
if(currItem->checkState() != checked)
currItem->setCheckState(checked);
else
cameraTree_recursiveCheck(currItem, checked);
}
}
示例14: onClickedAt
void ColorizerRow::onClickedAt (QModelIndex idx)
{
QStandardItem * item = m_model->itemFromIndex(idx);
Q_ASSERT(item);
QString const & str = m_model->data(idx, Qt::DisplayRole).toString();
bool const checked = (item->checkState() == Qt::Checked);
ColorizedRow & ct = findOrCreateColorizedRow(item->text());
if (checked)
{
append(str);
recompileColorRow(ct);
updateColorRow(ct);
}
else
{
recompileColorRow(ct);
updateColorRow(ct);
remove(str);
}
emitFilterChangedSignal();
/*
if (!idx.isValid()) return;
QStandardItemModel * model = static_cast<QStandardItemModel *>(m_config_ui.ui()->viewColorRow->model());
QStandardItem * item = model->itemFromIndex(idx);
Q_ASSERT(item);
QString const & val = model->data(idx, Qt::DisplayRole).toString();
bool const checked = (item->checkState() == Qt::Checked);
// @TODO: if state really changed
for (int i = 0, ie = m_filter_state.m_colorized_texts.size(); i < ie; ++i)
{
ColorizedRow & ct = m_filter_state.m_colorized_texts[i];
if (ct.m_row_str == val)
{
if (checked)
{
m_filter_state.setColorRowChecked(val, checked);
recompileColorRow(ct);
updateColorRow(ct);
}
else
{
uncolorRow(ct);
m_filter_state.setColorRowChecked(val, checked);
recompileColorRow(ct);
}
break;
}
}
*/
}
示例15:
QList<QSharedPointer<Shader> > ShaderListView::getCheckedShaders(){
QList<QSharedPointer<Shader> > list;
for(int i = 0; i < itemModel->rowCount();i++){
QStandardItem* item = itemModel->item(i);
if(item->checkState()){
int key = item->data().value<int>();
list.append(shaderMap.value(key));
}
}
return list;
}