本文整理汇总了C++中QStandardItem::setCheckable方法的典型用法代码示例。如果您正苦于以下问题:C++ QStandardItem::setCheckable方法的具体用法?C++ QStandardItem::setCheckable怎么用?C++ QStandardItem::setCheckable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStandardItem
的用法示例。
在下文中一共展示了QStandardItem::setCheckable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildList
void VegetationWidget::buildList()
{
QStringList extList;
extList << ".png" << ".tga" << ".osgb";
std::string plantDir = g_SystemContext._workContextDir;
plantDir.append(CONTEXT_DIR);
plantDir.append("/Plant/");
QString grassDir = chineseTextUTF8ToQString(plantDir + "Grass");
QStringList returnList;
findAllFilesByExt(grassDir, extList, returnList);
QStandardItemModel* grassModel = qobject_cast<QStandardItemModel*>(_grassListView->model());
grassModel->clear();
for (int i = 0; i < returnList.size(); ++i)
{
QFileInfo fileInfo = returnList.at(i);
QStandardItem* newItem = new QStandardItem(fileInfo.fileName());
setupIcon(newItem, "grass");
newItem->setCheckable(true);
grassModel->appendRow(newItem);
}
QString treeDir = chineseTextUTF8ToQString(plantDir + "Tree");
returnList.clear();
findAllFilesByExt(treeDir, extList, returnList);
QStandardItemModel* treeModel = qobject_cast<QStandardItemModel*>(_treeListView->model());
treeModel->clear();
for (int i = 0; i < returnList.size(); ++i)
{
QFileInfo fileInfo = returnList.at(i);
QStandardItem* newItem = new QStandardItem(fileInfo.fileName());
setupIcon(newItem, "tree");
newItem->setCheckable(true);
treeModel->appendRow(newItem);
}
}
示例2: showExample
void TreeView::showExample(void)
{
this->setColumn(1, 100,QStringLiteral("GPRS_STRUCT"));
for(int i = 0; i < 10; ++i)
{
QList<QStandardItem *> leve0;
QStandardItem * item = new QStandardItem(QString("GRPS_%0").arg(i));
item->setCheckable(1);//使能复选框
item->setIcon(QIcon(":/image/Aqua Ball.ico"));
leve0.append(item);
mode->appendRow(leve0);
for(int j = 0; j < 5; ++j)
{
QList<QStandardItem *> leve1;
QStandardItem * item = new QStandardItem(QString("Sensor_%0").arg(j));
item->setCheckable(1);//使能复选框
item->setIcon(QIcon(":/image/Aqua Ball Green.ico"));
leve1.append(item);
/* for(int i = 1; i < 4; ++i)
{
QStandardItem * item = new QStandardItem(QString("state_%0").arg(i));
leve1.append(item);
}*/
leve0.at(0)->appendRow(leve1);
}
}
// ui->treeView->setSelectionMode(QAbstractItemView::ExtendedSelection);//设置多选
this->setEditTriggers(0);//取消双击修改
this->setContextMenuPolicy(Qt::CustomContextMenu);//设置treeView右键单击产生相应信号,并设置连接
}
示例3: setShowCheckboxes
// Переключение режима отображения:
// checkable - с чек-боксами.
void qCheckboxFilterModel::setShowCheckboxes(bool checkable)
{
ShowCheckboxes = checkable;
if(checkable)
{
for(int r = 0; r < srcModel.rowCount(); ++r)
{
QStandardItem* item = actualSrcItem(r);
QString id = getSrcId(r);
item->setCheckable(true);
item->setData(VisibleItems[id]? Qt::Checked:Qt::Unchecked, Qt::CheckStateRole);
}
}
else
{
VisibleItems.clear();
for(int r = 0; r < srcModel.rowCount(); ++r)
{
QStandardItem* item = actualSrcItem(r);
QString id = getSrcId(r);
bool checked = (item->data(Qt::CheckStateRole).toInt() == Qt::Checked);
VisibleItems[id] = checked;
item->setCheckable(false);
item->setData(QVariant(), Qt::CheckStateRole);
}
}
invalidate();
}
示例4: getColumnItem
QStandardItem* getColumnItem(QStandardItem* parent, QString name, T& proxy)
{
QStandardItem* item = NULL;
QList<QStandardItem*> items = findChildItems(parent, name);
if (items.count() == 0)
{
// Create a new item because we did not find this item already
item = new QStandardItem(proxy.name);
item->setCheckState( (proxy.flag == 2 ? Qt::Checked : Qt::Unchecked) );
item->setCheckable(true);
parent->appendRow(item);
}
else if (items.count() > 1)
{
item = NULL;
}
else
{
item = items.at(0);
item->setCheckState( (proxy.flag == 2 ? Qt::Checked : Qt::Unchecked) );
item->setCheckable(true);
}
return item;
}
示例5: populateInputs
void GlobalSettingsConfig::populateInputs()/*{{{*/
{
m_inputsModel->clear();
QStringList alsaList;
QStringList jackList;
if(gInputList.size())
{
//Select the rows
for(int i = 0; i < gInputList.size(); ++i)
{
QPair<int, QString> input = gInputList.at(i);
if(input.first == MidiDevice::JACK_MIDI)
jackList.append(input.second);
else
alsaList.append(input.second);
}
}
for (iMidiDevice i = midiDevices.begin(); i != midiDevices.end(); ++i)
{
if ((*i)->deviceType() == MidiDevice::ALSA_MIDI)
{
if ((*i)->rwFlags() & 0x2)
{
QStandardItem* item = new QStandardItem(QString((*i)->name()).append(" (ALSA)"));
item->setData((*i)->name(), Qt::UserRole+1);
item->setData(MidiDevice::ALSA_MIDI, Qt::UserRole+2);
item->setEditable(false);
item->setCheckable(true);
if(alsaList.contains((*i)->name()))
item->setCheckState(Qt::Checked);
m_inputsModel->appendRow(item);
}
}
}
if(audioDevice->deviceType() != AudioDevice::JACK_AUDIO)
return;
std::list<QString> sl = audioDevice->outputPorts(true, false);//No aliases
for (std::list<QString>::iterator ip = sl.begin(); ip != sl.end(); ++ip)
{
QStandardItem* item = new QStandardItem(QString(*ip).append(" (JACK)"));
item->setData(*ip, Qt::UserRole+1);
item->setData(MidiDevice::JACK_MIDI, Qt::UserRole+2);
item->setEditable(false);
item->setCheckable(true);
if(jackList.contains(*ip))
item->setCheckState(Qt::Checked);
m_inputsModel->appendRow(item);
}
}/*}}}*/
示例6: appendItem
void WidgetBox::appendItem(const QString& text, QStandardItem* parent)
{
QStandardItem *item = new QStandardItem(text);
item->setEditable(false);
item->setCheckable(true);
parent->appendRow(item);
}
示例7: updateChannelConfig
void ChannelConfigModel::updateChannelConfig(const SongFormat *currentFormat)
{
this->removeRows(0, this->rowCount());
this->currentFormat = currentFormat;
if(currentFormat == nullptr)
{
return;
}
this->setRowCount(currentFormat->Voices);
for (int i = 0; i < currentFormat->Voices; i++)
{
const std::string &voiceName = currentFormat->VoiceName[i];
QStandardItem *item = new QStandardItem(QString::fromStdString(voiceName));
QBrush b(currentFormat->VoiceIsMuted[i] ? Qt::red : Qt::green);
item->setBackground(b);
QBrush f(currentFormat->VoiceIsMuted[i] ? Qt::white : Qt::black);
item->setForeground(f);
item->setTextAlignment(Qt::AlignCenter);
item->setCheckable(false);
item->setCheckState(currentFormat->VoiceIsMuted[i] ? Qt::Unchecked : Qt::Checked);
this->setItem(i, 0, item);
}
}
示例8: fillList
void CComDlg::fillList()
//////////////////////////
{
QStandardItemModel *model = (QStandardItemModel *)ui->listView->model();
model->removeRows(0, model->rowCount());
setCursor(Qt::WaitCursor);
QApplication::processEvents();
for (int i = 0; i < tComets.count(); i++)
{
comet_t *a = &tComets[i];
QStandardItem *item = new QStandardItem;
item->setText(a->name);
item->setCheckable(true);
item->setCheckState(a->selected ? Qt::Checked : Qt::Unchecked);
item->setEditable(false);
model->appendRow(item);
if ((i % 10000) == 0)
QApplication::processEvents();
}
setCursor(Qt::ArrowCursor);
}
示例9: dlg
/////////////////////////////////////////
// add new item
void CComDlg::on_pushButton_6_clicked()
/////////////////////////////////////////
{
comet_t a;
CComEdit dlg(this, true, &a);
if (dlg.exec() == DL_OK)
{
if (a.perihelionDate < minJD) minJD = a.perihelionDate;
if (a.perihelionDate > maxJD) maxJD = a.perihelionDate;
QStandardItemModel *model = (QStandardItemModel *)ui->listView->model();
QStandardItem *item = new QStandardItem;
a.selected = true;
item->setText(a.name);
item->setCheckable(true);
item->setCheckState(a.selected ? Qt::Checked : Qt::Unchecked);
item->setEditable(false);
model->appendRow(item);
tComets.append(a);
}
}
示例10: model
void tst_QItemDelegate::QTBUG4435_keepSelectionOnCheck()
{
QStandardItemModel model(3, 1);
for (int i = 0; i < 3; ++i) {
QStandardItem *item = new QStandardItem(QLatin1String("Item ") + QString::number(i));
item->setCheckable(true);
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
model.setItem(i, item);
}
QTableView view;
view.setModel(&model);
view.setItemDelegate(new TestItemDelegate);
view.show();
view.selectAll();
QVERIFY(QTest::qWaitForWindowExposed(&view));
QStyleOptionViewItem option;
option.rect = view.visualRect(model.index(0, 0));
// mimic QStyledItemDelegate::initStyleOption logic
option.features = QStyleOptionViewItem::HasDisplay | QStyleOptionViewItem::HasCheckIndicator;
option.checkState = Qt::CheckState(model.index(0, 0).data(Qt::CheckStateRole).toInt());
const int checkMargin = qApp->style()->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, 0) + 1;
QPoint pos = qApp->style()->subElementRect(QStyle::SE_ViewItemCheckIndicator, &option, 0).center()
+ QPoint(checkMargin, 0);
QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, pos);
QTRY_VERIFY(view.selectionModel()->isColumnSelected(0, QModelIndex()));
QCOMPARE(model.item(0)->checkState(), Qt::Checked);
}
示例11: reloadSettings
void ShowConfigDialog::reloadSettings ()
{
QSettings settings (QCoreApplication::organizationName (),
QCoreApplication::applicationName () + "_Sidebar");
settings.beginGroup (Context_);
const int size = settings.beginReadArray ("Actions");
for (int i = 0; i < size; ++i)
{
settings.setArrayIndex (i);
const auto& icon = settings.value ("Icon").value<QIcon> ();
QStandardItem *item = new QStandardItem (icon,
settings.value ("Text").toString ());
item->setCheckState (settings.value ("Enabled").toBool () ?
Qt::Checked :
Qt::Unchecked);
item->setToolTip (settings.value ("Tooltip").toString ());
item->setData (settings.value ("ID"), Roles::ActionID);
item->setCheckable (true);
item->setEditable (false);
Model_->appendRow (item);
}
settings.endArray ();
settings.endGroup ();
}
示例12: addImage
void ImageContainerWidget::addImage(const cv::Mat& image)
{
qDebug() << "saving image";
// push back image towards container
_images.push_back(image);
// save image to file
QString filename;
filename = "cali_images/image_" + QString::number(_images.size()) + ".png";
cv::imwrite(filename.toStdString(), image);
QStandardItemModel *model = static_cast<QStandardItemModel*>(_ui->tableView->model());
QStandardItem* item = new QStandardItem(filename);
item->setCheckable(true);
item->setCheckState(Qt::Checked);
model->setItem(_images.size(), 0, item);
for(unsigned int i=0 ; i<model->rowCount() ; i++)
{
QStandardItem* itemToCheck = model->item(i);
}
}
示例13: parsePluginNode
void PluginDialog::parsePluginNode(QDomNode node)
{
QString name = node.firstChildElement("name").text();
QString shortname = node.firstChildElement("shortname").text();
QString iconUrl = node.firstChildElement("icon").text();
QString category = node.firstChildElement("category").text();
QString downloadUrl = node.firstChildElement("download").text();
QString version = node.firstChildElement("version").text();
QIcon icon = NetworkUtils::getIconFromUrl(QUrl(iconUrl));
QList<QStandardItem *> rowItems;
QStandardItem* pluginItem = new QStandardItem(icon, name);
pluginItem->setData(shortname, Qt::UserRole);
pluginItem->setData(downloadUrl, Qt::UserRole + 1);
pluginItem->setData(version, Qt::UserRole + 2);
rowItems << pluginItem;
QStandardItem* enableItem = new QStandardItem("");
enableItem->setCheckable(true);
if(pluginManager->isInstalled(shortname))
{
enableItem->setCheckState(Qt::Checked);
}
rowItems << enableItem;
if(category != "local")
{
categoryOnline->appendRow(rowItems);
}else
{
categoryLocal->appendRow(rowItems);
}
}
示例14: QStringLiteral
void TreeView::showExample2(void)
{
this->setColumn(4, 100, QStringLiteral("Abnormal sensor"), QStringLiteral("state"));
for(int i = 0; i < 10; ++i)
{
QList<QStandardItem *> leve2;
QStandardItem * item = new QStandardItem(QString("GRPS_%0").arg(i));
item->setCheckable(1);//使能复选框
item->setIcon(QIcon(":/image/Aqua Ball Red.ico"));
item->setText(QString("%0").arg(i));
leve2.append(item);
for(int i = 1; i < 4; ++i)
{
QStandardItem * item = new QStandardItem(QString("state_%0").arg(i));
leve2.append(item);
}
mode->appendRow(leve2);
}
// ui->treeView->setSelectionMode(QAbstractItemView::ExtendedSelection);//设置多选
this->setEditTriggers(0);//取消双击修改
this->setContextMenuPolicy(Qt::CustomContextMenu);//设置treeView右键单击产生相应信号,并设置连接
}
示例15: initFromRPC
bool FeedModel::initFromRPC(QVariant *resp)
{
QList<QVariant> elements(resp->toList());
for (int i = 0; i < elements.size(); ++i) {
// parse element
QMap<QString, QVariant> tags = elements[i].toMap();
QString rssTitle;
QString imageUrl;
int rssId;
rssTitle = tags.value("title").toString();
rssId = tags.value("iid").toInt();
imageUrl = tags.value("image").toString();
QStandardItem *item = new QStandardItem(rssTitle);
item->setCheckable( true );
if(!imageUrl.isEmpty()) {
ResourceManager *rm = static_cast<NewsApplication*>(qApp)->getRM();
}
item->setData(rssId);
// m_root->appendRow(item);
}
return true;
}