本文整理汇总了C++中QStandardItem::setFont方法的典型用法代码示例。如果您正苦于以下问题:C++ QStandardItem::setFont方法的具体用法?C++ QStandardItem::setFont怎么用?C++ QStandardItem::setFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStandardItem
的用法示例。
在下文中一共展示了QStandardItem::setFont方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addMessage
void MessagesModel::addMessage(const QString &id, const QString &parentId, const QString &subject, const QString &from, const QDateTime &received, bool read)
{
QStandardItem *stdItem = findItem(id);
if (stdItem) {
return;
}
QList<QStandardItem*> items;
stdItem = new QStandardItem;
QFont font = stdItem->font();
font.setBold(true);
if (!read) {
stdItem->setFont(font);
}
stdItem->setText(from);
stdItem->setData(id, RoleMessageId);
stdItem->setData(parentId, RoleParentFolderId);
items << stdItem;
stdItem = new QStandardItem(subject);
if (!read) {
stdItem->setFont(font);
}
items << stdItem;
stdItem = new QStandardItem;
if (!read) {
stdItem->setFont(font);
}
stdItem->setData(received, Qt::DisplayRole);
items << stdItem;
appendRow(items);
}
示例2: checkIfMangaAreRead
void MangaListWidget::checkIfMangaAreRead(void) {
for (int k = 0; k < _model->rowCount(); k++) {
QStandardItem* currManga = _model->itemFromIndex(_model->index(k, 0));
QList<bool> areChaptersRead = Utils::areChaptersRead(currManga->text());
if (!Utils::isMangaRead(areChaptersRead))
currManga->setFont(QFont("", -1, 99));
else
currManga->setFont(QFont());
}
}
示例3: initModel
void MangaListWidget::initModel(QString mangaSelected) {
_scansDirectory.setFilter(QDir::Dirs);
QStringList dirsList = Utils::dirList(_scansDirectory);
_model->removeRows(0, _model->rowCount());
QModelIndex indexMangaSelected;
for (const QString& mangaName: dirsList) {
QString currDirStr = _scansDirectory.path() + "/" + mangaName;
QStandardItem* currItem = new QStandardItem(mangaName);
currItem->setEditable(false);
_model->appendRow(currItem);
QDir currDir(currDirStr);
QStringList currDirsList = Utils::dirList(currDir, true);
QList<bool> areChaptersRead = Utils::areChaptersRead(mangaName);
if (!Utils::isMangaRead(areChaptersRead))
currItem->setFont(QFont("", -1, 99));
else
currItem->setFont(QFont());
if (mangaName == mangaSelected) {
indexMangaSelected = _model->indexFromItem(currItem);
}
int k = 0;
for (const QString& currChStr: currDirsList) {
if (k >= areChaptersRead.size()) {
QMessageBox::critical(this, "List error", "Error while tempting to edit manga read flags whithin MangaListWidget::initModel.");
return;
}
bool isChapterRead = areChaptersRead.at(k);
QStandardItem* currChItem = new QStandardItem(currChStr);
currChItem->setEditable(false);
setTextAccordingToRead(currChItem, isChapterRead);
currItem->appendRow(currChItem);
k++;
}
}
if (indexMangaSelected.isValid()) {
_view->selectionModel()->setCurrentIndex(indexMangaSelected, QItemSelectionModel::Current);
}
decorateMangaNames();
}
示例4: optionChanged
void ConfigurationContentsWidget::optionChanged(const QString &option, const QVariant &value)
{
for (int i = 0; i < m_model->rowCount(); ++i)
{
QStandardItem *groupItem = m_model->item(i, 0);
if (!groupItem || !QString(option).startsWith(groupItem->text()))
{
continue;
}
for (int j = 0; j < groupItem->rowCount(); ++j)
{
QStandardItem *optionItem = groupItem->child(j, 0);
if (optionItem && option == QStringLiteral("%1/%2").arg(groupItem->text()).arg(optionItem->text()))
{
QFont font = optionItem->font();
font.setBold(value != SettingsManager::getDefaultValue(option));
optionItem->setFont(font);
groupItem->child(j, 2)->setText(value.toString());
break;
}
}
}
}
示例5: 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;
}
示例6: foreach
foreach (QComboBox *comboBox, comboBoxes) {
// insert title
int titleIndex = comboBox->count();
if (dimensionality != std::numeric_limits<int>::max())
comboBox->addItem(tr("%1D Descriptors").arg(dimensionality));
else
comboBox->addItem(tr("Other Descriptors"));
// set bold font for title and make it non-selectable
QStandardItem *item =
qobject_cast<QStandardItemModel *>(comboBox->model())->item(titleIndex);
if (item) {
QFont font_ = item->font();
font_.setBold(true);
item->setFont(font_);
item->setFlags(Qt::ItemIsEnabled);
}
// add a separator
comboBox->insertSeparator(comboBox->count());
// insert name of each descriptor
foreach (const QString &name, names)
comboBox->addItem(name);
}
示例7: resetModel
void resetModel()
{
q->clear();
QFont bold;
bold.setBold(true);
// Create one item for each day of week
for(int day = Qt::Monday; day <= Qt::Sunday; ++day) {
QStandardItem *dayItem = new QStandardItem(QDate::longDayName(day));
dayItem->setFont(bold);
dayItem->setData(day, WeekDayRole);
// Add availabilities to items
const QVector<DayAvailability> &avail = m_UserCalendar->availabilities(day);
for(int availabilityId = 0; availabilityId < avail.count(); ++availabilityId) {
for(int timeRangeId = 0; timeRangeId < avail.at(availabilityId).timeRangeCount(); ++timeRangeId) {
TimeRange range = avail.at(availabilityId).timeRangeAt(timeRangeId);
QStandardItem *time = new QStandardItem(tkTr(Trans::Constants::FROM_1_TO_2).arg(range.from.toString()).arg(range.to.toString()));
time->setData(day, WeekDayRole);
time->setData(range.from, HourFromRole);
time->setData(range.to, HourToRole);
time->setData(timeRangeId, TimeRangeIdRole);
time->setData(availabilityId, AvailIdRole);
time->setToolTip(time->text());
dayItem->appendRow(time);
}
}
if (dayItem->rowCount() > 0) {
dayItem->sortChildren(0);
}
q->invisibleRootItem()->appendRow(dayItem);
}
}
示例8: QStandardItem
QList<QStandardItem*> QDatabaseTableViewController::makeStandardItemListFromStringList(const QList<QString>& szStringList)
{
QList<QStandardItem*> listStandardItemList;
QStandardItem* pStandardItem;
QFont font;
QPalette palette = QApplication::palette(m_pDatabaseTableView);
QBrush nullbrush = palette.brush(QPalette::Disabled, QPalette::Text);
QList<QString>::const_iterator iter = szStringList.begin();
while(iter != szStringList.end())
{
//Getting an item from QList<QString> to add it to a QList<QStandardItem>
if((*iter).isNull()){
pStandardItem = new QStandardItem(QString("NULL"));
font = pStandardItem->font();
font.setItalic(true);
pStandardItem->setFont(font);
pStandardItem->setForeground(nullbrush);
} else {
pStandardItem = new QStandardItem(*iter);
}
pStandardItem->setEditable(true);
listStandardItemList.append(pStandardItem);
iter++;
}
return listStandardItemList;
}
示例9: QDialog
AjoutPrecedence::AjoutPrecedence(QWidget *parent) :
QDialog(parent),
ui(new Ui::AjoutPrecedence), nbTachesAjoutees(0)
{
ui->setupUi(this);
this->setModal(true);
ui->treeView->setEditTriggers(0);
EditeurTache::predecesseurs.clear();
for(QMap<QString, Projet*>::const_iterator it= ProjetManager::getInstance().getProjets().cbegin();
it!=ProjetManager::getInstance().getProjets().cend();
it++){//parcours des projets
QStandardItem* item = new QStandardItem((*it)->getNom());
QFont f = QFont();
f.setBold(true);
f.setUnderline(true);
item->setFont(f);
modele.appendRow(item);
for(QMap<QString, Tache*>::const_iterator it2 = (*it)->getTaches().cbegin();
it2!=(*it)->getTaches().cend();
it2++){//parcours des taches de chaque projet
QStandardItem* item2 = new QStandardItem((*it2)->getId());//création de l'identifiant de la tache
item2->setCheckable(true); //ajout de la checkbox
item->appendRow(item2); //ajout de item2 au projet
nbTachesAjoutees++;
}
}
ui->treeView->setModel(&modele);
QObject::connect(ui->pushButtonAnnuler, SIGNAL(clicked()),this,SLOT(close()));
QObject::connect(ui->pushButtonOK, SIGNAL(clicked()),this,SLOT(EnregistrerPred()));
}
示例10: headingItem
// Returns a heading item with the given text. Will create and add a new heading under \c parentIndex at \c position if no heading with that text exists yet. (Use -1 for \c position to append at the bottom.) If \c text is empty, will return the top-level (invisible root) item.
QStandardItem* AMWindowPaneModel::headingItem(const QString& text, QModelIndex parentIndex, int position) {
if(text.isEmpty())
return invisibleRootItem();
QList<QStandardItem*> searchItems = this->findItems(text);
foreach(QStandardItem* i, searchItems) {
if(isHeading(i->index()))
return i;
}
// Didn't find it... time to make it:
QStandardItem* newHeading = new QStandardItem(text);
newHeading->setFlags(Qt::ItemIsEnabled); // enabled, but should not be selectable
// graphics defaults:
QFont font = QFont("Lucida Grande", 10, QFont::Bold);
font.setCapitalization(QFont::AllUppercase);
newHeading->setFont(font);
newHeading->setData(QBrush(QColor::fromRgb(100, 109, 125)), Qt::ForegroundRole);
QStandardItem* parent = itemFromIndex(parentIndex);
if(parent) {
if(position < 0 || position > parent->rowCount())
position = parent->rowCount();
parent->insertRow(position, newHeading);
}
else {
if(position < 0 || position > rowCount())
position = rowCount();
insertRow(position, newHeading);
}
return newHeading;
}
示例11: fillTitle
void fillTitle(QComboBox* combo, const QString& s) {
combo->addItem(s);
QStandardItem* item = lastItem(combo);
QFont f;
f.setBold(true);
item->setFont(f);
item->setSelectable(false);
}
示例12: QStandardItem
// Returns the root tree item containing the whole datapack information
QStandardItem *packToItem(const QString &absPathToDescriptionFile, const PackCreationQueue &queue)
{
// Read datapack description file
DataPack::Pack pack;
pack.fromXmlFile(absPathToDescriptionFile);
// Create datapack items
QStandardItem *packItem = new QStandardItem(pack.name());
QFont bold;
bold.setBold(true);
packItem->setFont(bold);
packItem->setCheckable(true);
packItem->setCheckState(Qt::Checked);
QStandardItem *item = 0;
item = new QStandardItem(tkTr(Trans::Constants::_1_COLON_2)
.arg(tkTr(Trans::Constants::TYPE))
.arg(pack.dataTypeName()));
item->setToolTip(item->text());
packItem->appendRow(item);
item = new QStandardItem(tkTr(Trans::Constants::_1_COLON_2)
.arg(tkTr(Trans::Constants::LICENSE))
.arg(pack.description().data(PackDescription::LicenseName).toString()));
item->setToolTip(item->text());
packItem->appendRow(item);
item = new QStandardItem(tkTr(Trans::Constants::_1_COLON_2)
.arg(tkTr(Trans::Constants::VERSION))
.arg(pack.version()));
item->setToolTip(item->text());
packItem->appendRow(item);
item = new QStandardItem(tkTr(Trans::Constants::_1_COLON_2)
.arg(tkTr(Trans::Constants::VENDOR))
.arg(pack.vendor()));
item->setToolTip(item->text());
packItem->appendRow(item);
item = new QStandardItem(tkTr(Trans::Constants::_1_COLON_2)
.arg(tkTr(Trans::Constants::CREATION_DATE_TIME))
.arg(QLocale().toString(pack.description().data(PackDescription::CreationDate).toDate())));
item->setToolTip(item->text());
packItem->appendRow(item);
item = new QStandardItem(tkTr(Trans::Constants::_1_COLON_2)
.arg(tkTr(Trans::Constants::LAST_MODIFICATION))
.arg(QLocale().toString(pack.description().data(PackDescription::LastModificationDate).toDate())));
item->setToolTip(item->text());
packItem->appendRow(item);
if (_format == PackCreationModel::ShowByServer) {
item = new QStandardItem(tkTr(Trans::Constants::_1_COLON_2)
.arg(tkTr(Trans::Constants::QUEUE))
.arg(queue.sourceAbsolutePathFile()));
item->setToolTip(item->text());
packItem->appendRow(item);
}
_packItems.insert(pack.originalXmlConfigFileName(), packItem);
return packItem;
}
示例13: createTreeModel
void createTreeModel(const int treeItemReference, bool forceUpdate = false)
{
if (!forceUpdate && (m_ActualTreeModelColumn == treeItemReference))
return;
m_ActualTreeModelColumn = treeItemReference;
QFont bold;
bold.setBold(true);
if (!m_TreeModel) {
m_TreeModel = new QStandardItemModel;
} else {
m_TreeModel->clear();
}
QStandardItem *parentItem = m_TreeModel->invisibleRootItem();
QHash<QString, QStandardItem *> categories;
for(int i=0; i < m_FormDescr.count(); ++i) {
Form::FormIODescription *descr = m_FormDescr.at(i);
// Do not manage excluded forms
if (_excludeUids.contains(descr->data(Form::FormIODescription::UuidOrAbsPath).toString(), Qt::CaseInsensitive))
continue;
const QString &cat = descr->data(treeItemReference).toString();
QStandardItem *catItem = 0;
if (!categories.contains(cat)) {
QString catName = descr->data(treeItemReference).toString();
if (catName.isEmpty()) {
catName = QCoreApplication::translate("FormFilesSelectorWidget", "Default Forms");
}
catItem = new QStandardItem(catName);
catItem->setFont(bold);
categories.insert(cat, catItem);
parentItem->appendRow(catItem);
} else {
catItem = categories.value(cat);
}
QStandardItem *item = new QStandardItem(descr->data(FormIODescription::ShortDescription).toString());
item->setData(i, IndexRole);
catItem->appendRow(item);
// highlight ?
if (!m_HightlightUuid.isEmpty()) {
if (descr->data(FormIODescription::UuidOrAbsPath).toString()==m_HightlightUuid) {
item->setFont(bold);
}
}
}
}
示例14: CreateFontItem
QStandardItem* FontManagerDialog::CreateFontItem(QString itemText, QString fontName, QString defaultFontName)
{
QStandardItem *item = new QStandardItem(itemText);
if (!defaultFontName.isNull() && !defaultFontName.isEmpty() && defaultFontName.contains(fontName))
{
QFont itemFont = item->font();
itemFont.setBold(true);
item->setFont(itemFont);
}
return item;
}
示例15: populateStyles
bool QgsStyleExportImportDialog::populateStyles( QgsStyle *style )
{
// load symbols and color ramps from file
if ( mDialogMode == Import )
{
// NOTE mTempStyle is style here
if ( !style->importXml( mFileName ) )
{
QMessageBox::warning( this, tr( "Import error" ),
tr( "An error occurred during import:\n%1" ).arg( style->errorString() ) );
return false;
}
}
QStandardItemModel *model = qobject_cast<QStandardItemModel *>( listItems->model() );
model->clear();
// populate symbols
QStringList styleNames = style->symbolNames();
QString name;
for ( int i = 0; i < styleNames.count(); ++i )
{
name = styleNames[i];
QStringList tags = style->tagsOfSymbol( QgsStyle::SymbolEntity, name );
QgsSymbol *symbol = style->symbol( name );
QStandardItem *item = new QStandardItem( name );
QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( symbol, listItems->iconSize(), 15 );
item->setIcon( icon );
item->setToolTip( QString( "<b>%1</b><br><i>%2</i>" ).arg( name, tags.count() > 0 ? tags.join( ", " ) : tr( "Not tagged" ) ) );
// Set font to 10points to show reasonable text
QFont itemFont = item->font();
itemFont.setPointSize( 10 );
item->setFont( itemFont );
model->appendRow( item );
delete symbol;
}
// and color ramps
styleNames = style->colorRampNames();
for ( int i = 0; i < styleNames.count(); ++i )
{
name = styleNames[i];
std::unique_ptr< QgsColorRamp > ramp( style->colorRamp( name ) );
QStandardItem *item = new QStandardItem( name );
QIcon icon = QgsSymbolLayerUtils::colorRampPreviewIcon( ramp.get(), listItems->iconSize(), 15 );
item->setIcon( icon );
model->appendRow( item );
}
return true;
}