本文整理汇总了C++中QListWidgetItem::backgroundColor方法的典型用法代码示例。如果您正苦于以下问题:C++ QListWidgetItem::backgroundColor方法的具体用法?C++ QListWidgetItem::backgroundColor怎么用?C++ QListWidgetItem::backgroundColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QListWidgetItem
的用法示例。
在下文中一共展示了QListWidgetItem::backgroundColor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: settingsFromUi
Settings OptionsDialog::settingsFromUi()
{
Settings settings;
if (ui->scanInCurrentFileRadioButton->isChecked())
settings.scanningScope = ScanningScopeCurrentFile;
else if (ui->scanInSubprojectRadioButton->isChecked())
settings.scanningScope = ScanningScopeSubProject;
else
settings.scanningScope = ScanningScopeProject;
settings.keywords.clear();
for (int i = 0; i < ui->keywordsList->count(); ++i) {
QListWidgetItem *item = ui->keywordsList->item(i);
Keyword keyword;
keyword.name = item->text();
keyword.iconResource = item->data(Qt::UserRole).toString();
keyword.color = item->backgroundColor();
settings.keywords << keyword;
}
return settings;
}
示例2: editButtonClicked
void OptionsDialog::editButtonClicked()
{
QListWidgetItem *item = ui->keywordsList->currentItem();
Keyword keyword;
keyword.name = item->text();
keyword.iconResource = item->data(Qt::UserRole).toString();
keyword.color = item->backgroundColor();
KeywordDialog *addKeywordDialog = new KeywordDialog(keyword, this);
if (addKeywordDialog->exec() == QDialog::Accepted) {
keyword = addKeywordDialog->keyword();
item->setIcon(QIcon(keyword.iconResource));
item->setText(keyword.name);
item->setData(Qt::UserRole, keyword.iconResource);
item->setBackgroundColor(keyword.color);
}
}