本文整理汇总了C++中QStandardItem::font方法的典型用法代码示例。如果您正苦于以下问题:C++ QStandardItem::font方法的具体用法?C++ QStandardItem::font怎么用?C++ QStandardItem::font使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStandardItem
的用法示例。
在下文中一共展示了QStandardItem::font方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
}
}
}
示例3: 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;
}
示例4: 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);
}
示例5: 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);
}
示例6: 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;
}
示例7: streamItem
void tst_QStandardItem::streamItem()
{
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"));
QByteArray ba;
{
QDataStream ds(&ba, QIODevice::WriteOnly);
ds << item;
}
{
QStandardItem streamedItem;
QDataStream ds(&ba, QIODevice::ReadOnly);
ds >> streamedItem;
QCOMPARE(streamedItem.text(), item.text());
QCOMPARE(streamedItem.toolTip(), item.toolTip());
QCOMPARE(streamedItem.statusTip(), item.statusTip());
QCOMPARE(streamedItem.whatsThis(), item.whatsThis());
QCOMPARE(streamedItem.sizeHint(), item.sizeHint());
QCOMPARE(streamedItem.font(), item.font());
QCOMPARE(streamedItem.textAlignment(), item.textAlignment());
QCOMPARE(streamedItem.background(), item.background());
QCOMPARE(streamedItem.foreground(), item.foreground());
QCOMPARE(streamedItem.checkState(), item.checkState());
QCOMPARE(streamedItem.accessibleText(), item.accessibleText());
QCOMPARE(streamedItem.accessibleDescription(), item.accessibleDescription());
QCOMPARE(streamedItem.flags(), item.flags());
}
}
示例8: 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;
}
示例9: item
// ------------------------------------------------------------------
void
JcnModel::markEntry(int r, int markCol)
{
if (jcndbg)
std::cout << "JcnModel::markEntry r c" << std::endl;
QStandardItem * itm = item(r,markCol);
QFont f = itm->font();
f.setBold(true);
f.setUnderline(true);
f.setPixelSize(13);
itm->setFont(f);
}
示例10: paintEvent
void ObxTreeViewItem::paintEvent(QPaintEvent *)
{
if (view_.header().model() == 0 || data() == 0)
{
return;
}
QPainter p(this);
for(int i = 0; i < view_.header().model()->columnCount(); ++i)
{
QRect rc(view_.header().columnRect(i));
rc.setTop(MARGIN);
rc.setHeight(height() - 2 * MARGIN);
QStandardItem * item = view_.item(data(), i);
if (item != 0)
{
rc.adjust(ITEM_HEIGHT + MARGIN, MARGIN, -MARGIN * 4, -MARGIN);
if (i == 0)
{
rc.setLeft(rc.left() + obx::indent(item));
}
p.setOpacity(item->isSelectable() ? 1.0 : 0.5);
QIcon icon = item->icon();
p.drawPixmap(8, 8, icon.pixmap(84, 84));
QString title = item->text();
p.setFont(item->font());
chopStringByRect(p, rc, item->textAlignment()|Qt::AlignTop, title);
p.drawText(rc, item->textAlignment()|Qt::AlignTop, title);
QFont smallFont;
smallFont.setPointSize(16);
title = item->toolTip();
p.setFont(smallFont);
chopStringByRect(p, rc, Qt::AlignRight|Qt::AlignBottom, title);
p.drawText(rc, Qt::AlignRight|Qt::AlignBottom, title);
}
}
if (isSelected())
{
p.setOpacity(1);
QPen pen(Qt::SolidLine);
pen.setColor(Qt::black);
p.setPen(pen);
p.drawRoundedRect(rect().adjusted(0, 0, -1, -1), 8, 8);
}
}
示例11: clearDefaultRow
void Ui_pluginManagerWindow::clearDefaultRow(int defaultRow)
{
QStandardItemModel *model = (QStandardItemModel*)ui.pluginTableView->model();
QStandardItem *item = model->item(defaultRow, 0);
item->setData(false, PLUGIN_IS_DEFAULT);
for (int column = 0; column < model->columnCount(); column++)
{
QStandardItem *item = model->item(defaultRow, column);
QFont font = item->font();
font.setBold(false);
item->setFont(font);
}
}
示例12: updateDebuggerStandardItem
bool DebuggerItemModel::updateDebuggerStandardItem(const DebuggerItem &item, bool changed)
{
QStandardItem *sitem = findStandardItemById(item.id());
QTC_ASSERT(sitem, return false);
QStandardItem *parent = sitem->parent();
QTC_ASSERT(parent, return false);
int row = sitem->row();
QFont font = sitem->font();
font.setBold(changed);
parent->child(row, 0)->setData(item.displayName(), Qt::DisplayRole);
parent->child(row, 0)->setData(item.abiNames(), Qt::UserRole + 2);
parent->child(row, 0)->setFont(font);
parent->child(row, 1)->setData(item.command().toUserOutput(), Qt::DisplayRole);
parent->child(row, 1)->setFont(font);
parent->child(row, 2)->setData(item.engineTypeName(), Qt::DisplayRole);
parent->child(row, 2)->setData(static_cast<int>(item.engineType()));
parent->child(row, 2)->setFont(font);
return true;
}
示例13: populateLog
bool LogChangeWidget::populateLog(const QString &repository, const QString &commit, LogFlags flags)
{
const QString currentCommit = this->commit();
int selected = currentCommit.isEmpty() ? 0 : -1;
if (const int rowCount = m_model->rowCount())
m_model->removeRows(0, rowCount);
// Retrieve log using a custom format "Sha1:Subject [(refs)]"
GitClient *client = GitPlugin::instance()->gitClient();
QStringList arguments;
arguments << QLatin1String("--max-count=1000") << QLatin1String("--format=%h:%s %d");
arguments << (commit.isEmpty() ? QLatin1String("HEAD") : commit);
if (!(flags & IncludeRemotes))
arguments << QLatin1String("--not") << QLatin1String("--remotes");
QString output;
if (!client->synchronousLog(repository, arguments, &output, 0, VcsBasePlugin::NoOutput))
return false;
foreach (const QString &line, output.split(QLatin1Char('\n'))) {
const int colonPos = line.indexOf(QLatin1Char(':'));
if (colonPos != -1) {
QList<QStandardItem *> row;
for (int c = 0; c < ColumnCount; ++c) {
QStandardItem *item = new QStandardItem;
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
if (line.endsWith(QLatin1Char(')'))) {
QFont font = item->font();
font.setBold(true);
item->setFont(font);
}
row.push_back(item);
}
const QString sha1 = line.left(colonPos);
row[Sha1Column]->setText(sha1);
row[SubjectColumn]->setText(line.right(line.size() - colonPos - 1));
m_model->appendRow(row);
if (selected == -1 && currentCommit == sha1)
selected = m_model->rowCount() - 1;
}
}
setCurrentIndex(m_model->index(selected, 0));
return true;
}
示例14: populateCandidateObjects
void MpcImportWindow::populateCandidateObjects(QList<SsoElements> objects)
{
candidatesForAddition.clear();
//Get a list of the current objects
QHash<QString,QString> defaultSsoIdentifiers = ssoManager->getDefaultSsoIdentifiers();
QHash<QString,QString> loadedSsoIdentifiers = ssoManager->listAllLoadedSsoIdentifiers();
//Separating the objects into visual groups in the list
int newDefaultSsoIndex = 0;
int newLoadedSsoIndex = 0;
int newNovelSsoIndex = 0;
int insertionIndex = 0;
QStandardItemModel * model = candidateObjectsModel;
model->clear();
model->setColumnCount(1);
foreach (SsoElements object, objects)
{
QString name = object.value("name").toString();
if (name.isEmpty())
continue;
QString group = object.value("section_name").toString();
if (group.isEmpty())
continue;
//Prevent name conflicts between asteroids and moons
if (loadedSsoIdentifiers.contains(name))
{
if (loadedSsoIdentifiers.value(name) != group)
{
name.append('*');
object.insert("name", name);
}
}
QStandardItem * item = new QStandardItem();
item->setText(name);
item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
item->setCheckState(Qt::Unchecked);
if (defaultSsoIdentifiers.contains(name))
{
//Duplicate of a default solar system object
QFont itemFont(item->font());
itemFont.setBold(true);
item->setFont(itemFont);
candidatesForUpdate.append(object);
insertionIndex = newDefaultSsoIndex;
newDefaultSsoIndex++;
newLoadedSsoIndex++;
newNovelSsoIndex++;
}
else if (loadedSsoIdentifiers.contains(name))
{
//Duplicate of another existing object
QFont itemFont(item->font());
itemFont.setItalic(true);
item->setFont(itemFont);
candidatesForUpdate.append(object);
insertionIndex = newLoadedSsoIndex;
newLoadedSsoIndex++;
newNovelSsoIndex++;
}
else
{
candidatesForAddition.append(object);
insertionIndex = newNovelSsoIndex;
newNovelSsoIndex++;
}
model->insertRow(insertionIndex, item);
}
示例15: fillInfo
void CLvQInfo::fillInfo(ofiItem_t *data, bool update)
/////////////////////////////////////////////////////
{
m_bFilled = true;
m_info = *data;
m_parent->setItemText(0, tr("Quick information : ") + data->title);
QStandardItemModel *m = (QStandardItemModel *)model();
if (!update)
{
m->removeRows(0, m->rowCount());
}
for (int i = 0; i < data->tTextItem.count(); i++)
{
ofiTextItem_t *item = &data->tTextItem[i];
if (update)
{
m->item(i, 1)->setText(item->value);
}
else
{
QList <QStandardItem *> tRow;
QStandardItem *label = new QStandardItem;
QStandardItem *value = new QStandardItem;
QFont f = label->font();
f.setPointSizeF(f.pointSizeF() - 0.25);
label->setFont(f);
value->setFont(f);
label->setText(item->label);
label->setToolTip(item->label);
if (item->bBold)
{
QFont f = label->font();
f.setBold(true);
label->setFont(f);
}
if (!item->bIsTitle)
{
value->setText(item->value);
value->setToolTip(item->value);
}
tRow.append(label);
tRow.append(value);
m->appendRow(tRow);
if (item->bIsTitle)
{
setFirstColumnSpanned(i, QModelIndex(), true);
}
}
}
}