本文整理汇总了C++中QListWidgetItem::checkState方法的典型用法代码示例。如果您正苦于以下问题:C++ QListWidgetItem::checkState方法的具体用法?C++ QListWidgetItem::checkState怎么用?C++ QListWidgetItem::checkState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QListWidgetItem
的用法示例。
在下文中一共展示了QListWidgetItem::checkState方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateFilteredElements
void SelectionWindow::updateFilteredElements()
{
if (!_score)
return;
int filter = _score->selectionFilter().filtered();
bool all = true;
bool none = true;
_listWidget->blockSignals(true);
for(int row = 1; row < _listWidget->count(); row++) {
QListWidgetItem *item = _listWidget->item(row);
if (filter & 1 << (row - 1)) {
if (item->checkState() != Qt::Checked)
item->setCheckState(Qt::Checked);
none = false;
}
else {
if (item->checkState() != Qt::Unchecked)
item->setCheckState(Qt::Unchecked);
all = false;
}
}
QListWidgetItem *item = _listWidget->item(0);
Qt::CheckState state = all ? Qt::Checked : (none ? Qt::Unchecked : Qt::PartiallyChecked);
if (item->checkState() != state)
item->setCheckState(state);
_listWidget->blockSignals(false);
}
示例2: GetCheckedState
StatePropertyGridWidget::eCheckedState StatePropertyGridWidget::GetCheckedState()
{
eCheckedState state = STATE_PARTIALLY_CHECKED;
bool everyItemUnchecked = true;
bool everyItemChecked = true;
for (int32 i = 0; i < ui->stateSelectListWidget->count(); ++i)
{
QListWidgetItem* item = ui->stateSelectListWidget->item(i);
everyItemChecked &= (item->checkState() == Qt::Checked);
everyItemUnchecked &= (item->checkState() == Qt::Unchecked);
}
if (everyItemChecked)
{
state = STATE_EVERY_ITEM_CHECKED;
}
if (everyItemUnchecked)
{
state = STATE_EVERY_ITEM_UNCHECKED;
}
return state;
}
示例3: on_buttonBox_accepted
//OK pressed
void UpdateAvailiableDialog::on_buttonBox_accepted()
{
QListWidgetItem *AppItem = ui->listWidget->item(0);
QListWidgetItem *UpdateItem = ui->listWidget->item(1);
//check if any updates are selected
bool UpdateApp = (!AppItem->isHidden() && AppItem->checkState() == Qt::Checked);
bool UpdateUpdater = (!UpdateItem->isHidden() && UpdateItem->checkState() == Qt::Checked);
emit Update(UpdateApp,UpdateUpdater);
}
示例4: listsToXML
//XML
//Converts the given lists and puts them in an XML tree
QString TaskList_Main::listsToXML(const QListWidget &inList){
QDomDocument doc;
QDomProcessingInstruction instr = doc.createProcessingInstruction(
"xml", "version='1.0' encoding='UTF-8'");
doc.appendChild(instr);
//Create list to hold individual task lists
QDomElement listElement = addElement(doc, doc, "listset");
//Iteratore through available 'lists'
for(int i = 0; i < inList.count(); ++i){
QDomElement list = addElement(doc, listElement, "list");
addElement(doc, list, "list_title", inList.item(i)->text());
//Find associated note mapping
my_listwidget *listPtr = notePane->listMap[inList.item(i)];
//Iterates through 'tasks' in 'list'
bool nextIsSub = false;
for(int j = 0; j < listPtr->count(); ++j){
QDomElement task = addElement(doc, list, "task");
QListWidgetItem *taskPtr = listPtr->item(j);
//If next item is subtext...
if(nextIsSub){
nextIsSub = false;
task.setAttribute("task_type", "sub");
addElement(doc, task, "task_title", taskPtr->text());
addElement(doc, task, "task_font", taskPtr->font().toString());
}
//Else, we know it's main task
else{
task.setAttribute("task_type", "main");
addElement(doc, task, "task_title", taskPtr->text());
if(taskPtr->checkState() == Qt::Unchecked)
addElement(doc, task, "task_check", "unchecked");
if(taskPtr->checkState() == Qt::Checked)
addElement(doc, task, "task_check", "checked");
if(taskPtr->checkState() == Qt::PartiallyChecked)
addElement(doc, task, "task_check", "part_check");
addElement(doc, task, "task_note", taskPtr->data(32).toString());
addElement(doc, task, "task_display", taskPtr->data(33).toString());
addElement(doc, task, "task_date", taskPtr->data(34).toDate().toString(Qt::ISODate));
addElement(doc, task, "task_font", taskPtr->font().toString());
if(taskPtr->data(35).toBool() == true){
nextIsSub = true;
}
}
}
}
//Return DOM document
return doc.toString();
}
示例5: add
/*
* Add highlighted entries into main data store
*/
void UploadImpl::add()
{
// checked rather than selected seems more intuitive
// QList<QListWidgetItem *> items;
// items = listWidget->selectedItems();
for (int n=0; n< listWidget->count(); ++n)
{
QListWidgetItem* i = listWidget->item(n);
if ( (i->checkState() == Qt::Checked) &&
(i->flags() & Qt::ItemIsEnabled) )
{
// userrole data contains location exercise list
unsigned int pos = i->data(Qt::UserRole).toInt();
//Disable once uploaded
i->setFlags(0);
i->setCheckState(Qt::Checked);
// TODO add session ids to remove this date grouping hack.
QDateTime initial(exdata[pos].date, exdata[pos].time);
std::vector<ExerciseSet> sets;
while (pos < exdata.size() &&
QDateTime(exdata[pos].date, exdata[pos].time) == initial)
{
sets.push_back(exdata[pos++]);
}
if (sets.size())
ds->add(sets);
}
}
close();
}
示例6: on_btn_ok_clicked
void EditUserDlg::on_btn_ok_clicked()
{
if( !isNameRight() )
return;
m_user.m_strName = ui->edit_name->text();
m_user.m_strPassword = ui->edit_password->text();
m_user.m_strDescrip = ui->edit_description->text();
m_groupNames.clear();
//需要添加用户组隶属信息
for(int i=0; i<ui->listWidget->count(); i++)
{
QListWidgetItem *item = ui->listWidget->item(i);
if(item && item->checkState() == Qt::Checked)
{
m_groupNames << item->text();
}
}
if(m_groupNames.size() == 0 && iOpenType == 0)
{
QMessageBox box(QMessageBox::Warning,tr("警告"),tr("默认用户没有相应的组对应!"),QMessageBox::Ok|QMessageBox::No,this,Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
box.button(QMessageBox::Ok)->setText(tr("确定"));
box.button(QMessageBox::No)->setText(tr("取消"));
box.exec();
if(box.clickedButton()== box.button(QMessageBox::No))
{
return;
}
}
accept();
}
示例7: on_exportButton_clicked
void StatWidget::on_exportButton_clicked()
{
QString filepath = ui.dirLineEdit->text() + "/" + ui.fileNameLineEdit->text();
QFile file(filepath);
file.open(QFile::WriteOnly);
QTextStream out(&file);
// QTableWidgetItem *item;
for (int headnum = 0; headnum < tableHeader.size(); headnum++ ) {
out << tableHeader.at(headnum) << "\t";
}
out << "\n";
QListWidgetItem *item;
int row = 0;
for (int i = 0; i < ui.listWidget->count(); i++) {
item = ui.listWidget->item(i);
if (item->checkState() == Qt::Checked) {
row++;
}
}
int column = ui.tableWidget->columnCount();
for (int i = 0; i < row; i++)
{
for(int j = 0; j < column; j++)
{
out<< ui.tableWidget->item(i, j)->text()<<"\t";
}
out<<"\n";
}
file.close();
ui.showLabel->setText(tr("导出成功!"));
}
示例8: do_save_color_ranges
QStringList MainWindow::do_save_color_ranges(QString &base)
{
QMap<QString, rc_map> jobs;
const QString& palId = current_pal_name();
const QList<QRgb>& palData = current_pal_data();
QStringList needOverwriteFiles;
for(int k = 0; k < ui->listRanges->count(); ++k) {
QListWidgetItem* itemw = ui->listRanges->item(k);
Q_ASSERT(itemw);
if(itemw->checkState() == Qt::Checked) {
const QString& rangeId = itemw->data(Qt::UserRole).toString();
const QString& filePath = base + "/" + QFileInfo(img_path_).completeBaseName() +
"-RC-" + palId + "-" + QString::number(k + 1) +
"-" + rangeId + ".png";
jobs[filePath] = recolor_range(color_ranges_.value(rangeId), palData);
if(QFileInfo(filePath).exists()) {
needOverwriteFiles.push_back(filePath);
}
}
}
if(!needOverwriteFiles.isEmpty() && !confirm_existing_files(needOverwriteFiles)) {
throw canceled_job();
}
return do_run_jobs(jobs);
}
示例9: togglePlaneVisibility
void FlightVisualization::togglePlaneVisibility(QListWidgetItem * item)
{
if (item->text().startsWith(ALL_PLANES_LABEL)) {
for (int index = 0; index < popupPlaneSelector->count(); index++) {
QListWidgetItem * newItem = popupPlaneSelector->item(index);
newItem->setCheckState(item->checkState());
int planeIndex = newItem->text().remove(DISP_PLANE_PREFIX).toInt();
QString visible = "false";
if (newItem->checkState() > 0) {
visible = "true";
}
QString function = QString("togglePlaneVisibility(%1, %2)").arg(
planeIndex).arg(visible);
ui->webView->page()->currentFrame()->documentElement().evaluateJavaScript(
function);
}
} else {
int planeIndex = item->text().remove(DISP_PLANE_PREFIX).toInt();
QString visible = "false";
if (item->checkState() > 0) {
visible = "true";
}
QString function = QString("togglePlaneVisibility(%1, %2)").arg(
planeIndex).arg(visible);
ui->webView->page()->currentFrame()->documentElement().evaluateJavaScript(
function);
}
}
示例10: on_buttonBox_accepted
void repair::on_buttonBox_accepted()
{
QListWidgetItem *item = _listinstalled->currentItem();
if (_listinstalled->count() && item)
{ //Some OSes are selected
for(int row = 0; row < ui->listWidget->count(); row++)
{
QListWidgetItem * actionitem = ui->listWidget->item(row);
if (actionitem->checkState() == Qt::Checked)
{
QVariantMap m = actionitem->data(Qt::UserRole).toMap();
if (m["action"] == "fscheck")
{
fscheck dlg(_listinstalled);
dlg.exec();
}
if (m["action"] == "setup")
{
rerunsetup dlg(_listinstalled,_mw,_drive);
dlg.exec();
}
if (m["action"] == "upgrade")
{
/*xxx dlg(_listinstalled);
dlg.exec();*/
}
}
}
}
}
示例11:
bool
user_edit_dialog::update_granted_roles(user& u, db_ctxt* dbc)
{
// Re-read the roles from database, compare to our list and
// run GRANT or REVOKE accordingly
bool ok=true;
QList<QString> assigned_roles = user::granted_roles(m_role_oid);
const QString username = u.m_login;
for (int i=0; i<m_qlist_roles->count(); i++) {
QListWidgetItem* item = m_qlist_roles->item(i);
if (item->checkState()==Qt::Checked) {
if (assigned_roles.indexOf(item->text()) < 0) {
// checked but not granted => grant it
ok=user::grant_role(username, item->text(), dbc);
if (!ok) break;
assigned_roles.append(item->text());
}
}
else {
if (assigned_roles.indexOf(item->text()) >= 0) {
// not checked but granted => revoke it
ok = user::revoke_role(username, item->text(), dbc);
if (!ok) break;
}
}
}
return ok;
}
示例12: actionBreakpoints
void SkDebuggerGUI::actionBreakpoints() {
fBreakpointsActivated = !fBreakpointsActivated;
for (int row = 0; row < fListWidget.count(); row++) {
QListWidgetItem *item = fListWidget.item(row);
item->setHidden(item->checkState() == Qt::Unchecked && fBreakpointsActivated);
}
}
示例13: getData
void PrefAssociations::getData(Preferences *)
{
qDebug("PrefAssociations::getData: something_changed: %d", something_changed);
if (!something_changed) return;
QStringList extensions;
for (int k = 0; k < listWidget->count(); k++)
{
QListWidgetItem* pItem = listWidget->item(k);
if (pItem && pItem->checkState() == Qt::Checked)
extensions.append(pItem->text());
}
int processed = ProcessAssociations(extensions, m_regExtensions);
if (processed != extensions.count())
{
QMessageBox::warning(this, tr("Warning"),
tr("Not all files could be associated. Please check your "
"security permissions and retry."), QMessageBox::Ok);
}
refreshList(); //Useless when OK is pressed... How to detect if apply or ok is pressed ?
something_changed = false;
}
示例14: save
void PluginsManager::save()
{
if (!m_loaded) {
return;
}
QStringList allowedPlugins;
for (int i = 0; i < ui->list->count(); i++) {
QListWidgetItem* item = ui->list->item(i);
if (item->checkState() == Qt::Checked) {
const Plugins::Plugin plugin = item->data(Qt::UserRole + 10).value<Plugins::Plugin>();
// Save plugins with relative path in portable mode
if (mApp->isPortable())
allowedPlugins.append(plugin.fileName);
else
allowedPlugins.append(plugin.fullPath);
}
}
Settings settings;
settings.beginGroup("Plugin-Settings");
settings.setValue("EnablePlugins", ui->allowAppPlugins->isChecked());
settings.setValue("AllowedPlugins", allowedPlugins);
settings.endGroup();
}
示例15: putToCache
/* Save data from corresponding widgets to cache,
* this task SHOULD be performed in GUI thread only: */
void UIMachineSettingsSystem::putToCache()
{
/* Prepare system data: */
UIDataSettingsMachineSystem systemData = m_cache.base();
/* Gather system data: */
systemData.m_bootItems.clear();
for (int i = 0; i < mTwBootOrder->count(); ++i)
{
QListWidgetItem *pItem = mTwBootOrder->item(i);
UIBootItemData data;
data.m_type = static_cast<UIBootTableItem*>(pItem)->type();
data.m_fEnabled = pItem->checkState() == Qt::Checked;
systemData.m_bootItems << data;
}
systemData.m_fIoApicEnabled = mCbApic->isChecked() || mSlCPU->value() > 1 ||
(KChipsetType)mCbChipset->itemData(mCbChipset->currentIndex()).toInt() == KChipsetType_ICH9;
systemData.m_fEFIEnabled = mCbEFI->isChecked();
systemData.m_fUTCEnabled = mCbTCUseUTC->isChecked();
systemData.m_fUseAbsHID = mCbUseAbsHID->isChecked();
systemData.m_fPAEEnabled = mCbPae->isChecked();
systemData.m_fHwVirtExEnabled = mCbVirt->checkState() == Qt::Checked || mSlCPU->value() > 1;
systemData.m_fNestedPagingEnabled = mCbNestedPaging->isChecked();
systemData.m_iRAMSize = mSlMemory->value();
systemData.m_cCPUCount = mSlCPU->value();
systemData.m_cCPUExecCap = mSlCPUExecCap->value();
systemData.m_chipsetType = (KChipsetType)mCbChipset->itemData(mCbChipset->currentIndex()).toInt();
/* Cache system data: */
m_cache.cacheCurrentData(systemData);
}