本文整理汇总了C++中QTreeWidgetItem::font方法的典型用法代码示例。如果您正苦于以下问题:C++ QTreeWidgetItem::font方法的具体用法?C++ QTreeWidgetItem::font怎么用?C++ QTreeWidgetItem::font使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTreeWidgetItem
的用法示例。
在下文中一共展示了QTreeWidgetItem::font方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_deleteToolButton_clicked
void ProfileDialog::on_deleteToolButton_clicked()
{
QTreeWidgetItem *item = pd_ui_->profileTreeWidget->currentItem();
if (item) {
GList *fl_entry = VariantPointer<GList>::asPtr(item->data(0, Qt::UserRole));
profile_def *profile = (profile_def *) fl_entry->data;
if (profile->is_global || item->font(0).strikeOut()) {
return;
}
if (profile->status == PROF_STAT_DEFAULT) {
QFont ti_font = item->font(0);
ti_font.setStrikeOut(true);
item->setFont(0, ti_font);
updateWidgets();
} else {
delete item;
// Select the default
pd_ui_->profileTreeWidget->setCurrentItem(pd_ui_->profileTreeWidget->topLevelItem(0));
remove_from_profile_list(fl_entry);
}
}
}
示例2: font
QFont QTreeWidgetItemProto::font(int column) const
{
QTreeWidgetItem *item = qscriptvalue_cast<QTreeWidgetItem*>(thisObject());
if (item)
return item->font(column);
return QFont();
}
示例3: reloadEmployeeList
void EmployeeCentre::reloadEmployeeList()
{
ui->trvEmployees->invisibleRootItem()->takeChildren();
QSqlQuery qu = QSqlDatabase::database().exec("SELECT * FROM Employees");
if (qu.lastError().isValid()){
PayrollMainWindow::instance()->showQueryError(qu);
return;
}
//All Ok
while (qu.next()) {
QString id = qu.record().value("EmployeeID").toString();
QString combinedName = qu.record().value("FirstName").toString() + " "
+ qu.record().value("MiddleName").toString() + " "
+ qu.record().value("LastName").toString();
QTreeWidgetItem *it = new QTreeWidgetItem(ui->trvEmployees);
it->setText(0, combinedName);
it->setText(99, id);
if (id == currentEmployeeId) {
//This is the current employee
QFont fnt = it->font(0);
fnt.setBold(true);
it->setFont(0, fnt);
ui->trvEmployees->scrollToItem(it);
}
}
ui->trvEmployees->resizeColumnToContents(0);
}
示例4: QTreeWidget
CategoryWidget::CategoryWidget(QWidget *parent) : QTreeWidget(parent), d(new CategoryWidgetPrivate()) {
connect(this, SIGNAL(clicked(QModelIndex)), this, SLOT(toggleItemState(QModelIndex)));
connect(this, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), this, SLOT(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)));
// get elements from the element manager
QStringList categories = ElementManager::instance()->categories();
// create the category nodes
QHash<QString, QTreeWidgetItem *> categoryNodes;
foreach(QString category, categories) {
QTreeWidgetItem *parent = 0;
int numSections = category.count("/") + 1;
for (int i = 0; i < numSections; ++i) {
QString path = category.section("/", 0, i, QString::SectionSkipEmpty);
if (!categoryNodes.contains(path)) {
QTreeWidgetItem *node = new QTreeWidgetItem();
if (parent == 0)
this->addTopLevelItem(node);
else
parent->addChild(node);
QString name = category.section("/", i, i, QString::SectionSkipEmpty);
node->setText(0, qApp->translate("Categories", name.toUtf8()));
node->setData(0, Qt::UserRole, name);
node->setData(1, Qt::UserRole, path);
// use bigger fonts for items at higher levels
QFont font = node->font(0);
font.setPointSize(font.pointSize() + 2 - qMin(i, 3));
node->setFont(0, font);
if (i >= 3)
node->setTextColor(0, QColor(96, 96, 96));
categoryNodes[path] = node;
}
parent = categoryNodes[path];
}
}
示例5: updateItem
void PreferencesDialog::updateItem(QTreeWidgetItem &item)
{
pref_t *pref = item.data(pref_ptr_col_, Qt::UserRole).value<pref_t *>();
if (!pref) return;
QString cur_value = gchar_free_to_qstring(prefs_pref_to_str(pref, pref_stashed)).remove(QRegExp("\n\t"));
bool is_changed = false;
QFont font = item.font(0);
if (pref->type == PREF_UAT || pref->type == PREF_CUSTOM) {
item.setText(1, tr("Unknown"));
} else if (stashedPrefIsDefault(pref)) {
item.setText(1, tr("Default"));
} else {
item.setText(1, tr("Changed"));
is_changed = true;
}
font.setBold(is_changed);
item.setFont(0, font);
item.setFont(0, font);
item.setFont(1, font);
item.setFont(2, font);
item.setFont(3, font);
item.setText(3, cur_value);
}
示例6: AddItems
void ImportedBookmarksPreviewDialog::AddItems()
{
const int rootFolderIntId = (elist->importSource == ImportedEntityList::Source_Firefox ? 1 : 0);
ui->chkRemoveImportedFile->setVisible(elist->importSource == ImportedEntityList::Source_Files);
ui->chkRemoveImportedFile->setChecked(elist->removeImportedFiles);
int index = 0;
foreach (const ImportedBookmarkFolder& ibf, elist->ibflist)
{
QTreeWidgetItem* twi = new QTreeWidgetItem();
twi->setText(0, ibf.title);
twi->setIcon(0, icon_folder);
twi->setData(0, TWID_IsFolder, true);
twi->setData(0, TWID_Index, index);
folderItems[ibf.intId] = twi;
index++;
//On Firefox, files and Urls, don't add or show the root folder.
if (ibf.intId == rootFolderIntId && (elist->importSource == ImportedEntityList::Source_Firefox ||
elist->importSource == ImportedEntityList::Source_Files ||
elist->importSource == ImportedEntityList::Source_Urls))
continue;
if (ibf.parentId <= rootFolderIntId)
ui->twBookmarks->addTopLevelItem(twi);
else
folderItems[ibf.parentId]->addChild(twi);
}
index = 0;
foreach (const ImportedBookmark& ib, elist->iblist)
{
QTreeWidgetItem* twi = new QTreeWidgetItem();
twi->setText(0, ib.title);
SetBookmarkItemIcon(twi, ib);
twi->setToolTip(0, ib.uri);
twi->setData(0, TWID_IsFolder, false);
twi->setData(0, TWID_Index, index);
bookmarkItems[ib.intId] = twi;
index++;
if (ib.title.trimmed().isEmpty())
{
//For [title-less bookmarks] show their url in a different formatting.
twi->setText(0, Util::FullyPercentDecodedUrl(ib.uri));
twi->setTextColor(0, QColor(192, 128, 0));
QFont italicFont = twi->font(0);
italicFont.setItalic(true);
twi->setFont(0, italicFont);
}
if (ib.parentId <= 0)
ui->twBookmarks->addTopLevelItem(twi);
else
folderItems[ib.parentId]->addChild(twi);
}
ui->twBookmarks->expandAll();
ui->twBookmarks->setCurrentItem(ui->twBookmarks->topLevelItem(0));
}
示例7: fillTransportList
void TransportListView::fillTransportList()
{
// try to preserve the selection
int selected = -1;
if ( currentItem() ) {
selected = currentItem()->data( 0, Qt::UserRole ).toInt();
}
clear();
foreach ( Transport *t, TransportManager::self()->transports() ) {
QTreeWidgetItem *item = new QTreeWidgetItem( this );
item->setData( 0, Qt::UserRole, t->id() );
QString name = t->name();
if ( TransportManager::self()->defaultTransportId() == t->id() ) {
name += i18nc( "@label the default mail transport", " (Default)" );
QFont font( item->font(0) );
font.setBold( true );
item->setFont( 0, font );
}
item->setText( 0, name );
item->setText( 1, t->transportType().name() );
if ( t->id() == selected ) {
setCurrentItem( item );
}
}
示例8: updateItemLook
void LocalVariableEditor::updateItemLook( QtBrowserItem *item )
{
VariableEditor::updateItemLook(item);
QTreeWidgetItem* pTreeItem = browserItemToItem(item);
QFont font = pTreeItem->font(0);
auto pVariable = m_pManager->getVariable(item->property());
if(item->property()->propertyName() == "this" && pVariable)
{
font.setBold(true);
}
else
{
font.setBold(false);
}
pTreeItem->setFont(0, font);
if(pVariable == nullptr
AND NOT(item->property()->propertyName().isEmpty())
AND getLocalVariableModel()->isWatchProperty(item->property()))
{
setBackgroundColor(item, QColor(255,0,0,64));
}
else
{
setBackgroundColor(item, calculatedBackgroundColor(item));
}
}
示例9: populateTreeWidget
void ccPluginDlg::populateTreeWidget(QObject *plugin, const QString &name, const QString &path)
{
QTreeWidgetItem *pluginItem = new QTreeWidgetItem(treeWidget);
pluginItem->setText(0, name);
treeWidget->setItemExpanded(pluginItem, true);
QFont boldFont = pluginItem->font(0);
boldFont.setBold(true);
pluginItem->setFont(0, boldFont);
if ( !path.isEmpty() )
{
pluginItem->setToolTip( 0, path );
}
if ( plugin == nullptr )
return;
ccPluginInterface *ccPlugin = qobject_cast<ccPluginInterface*>(plugin);
if ( ccPlugin == nullptr )
return;
QStringList features;
features += QString("name: %1").arg(ccPlugin->getName());
addItems(pluginItem, "CloudCompare Plugin", features);
}
示例10: fnt
void K3b::DataMultisessionImportDialog::addMedium( const K3b::Medium& medium )
{
QTreeWidgetItem* mediumItem = new QTreeWidgetItem( d->sessionView );
QFont fnt( mediumItem->font(0) );
fnt.setBold( true );
mediumItem->setText( 0, medium.shortString() );
mediumItem->setFont( 0, fnt );
mediumItem->setIcon( 0, QIcon::fromTheme("media-optical-recordable") );
const K3b::Device::Toc& toc = medium.toc();
QTreeWidgetItem* sessionItem = 0;
int lastSession = 0;
for ( K3b::Device::Toc::const_iterator it = toc.begin(); it != toc.end(); ++it ) {
const K3b::Device::Track& track = *it;
if( track.session() != lastSession ) {
lastSession = track.session();
QString sessionInfo;
if ( track.type() == K3b::Device::Track::TYPE_DATA ) {
K3b::Iso9660 iso( medium.device(), track.firstSector().lba() );
if ( iso.open() ) {
sessionInfo = iso.primaryDescriptor().volumeId;
}
}
else {
int numAudioTracks = 1;
while ( it != toc.end()
&& ( *it ).type() == K3b::Device::Track::TYPE_AUDIO
&& ( *it ).session() == lastSession ) {
++it;
++numAudioTracks;
}
--it;
sessionInfo = i18np("1 audio track", "%1 audio tracks", numAudioTracks );
}
sessionItem = new QTreeWidgetItem( mediumItem, sessionItem );
sessionItem->setText( 0, i18n( "Session %1", lastSession )
+ ( sessionInfo.isEmpty() ? QString() : " (" + sessionInfo + ')' ) );
if ( track.type() == K3b::Device::Track::TYPE_AUDIO )
sessionItem->setIcon( 0, QIcon::fromTheme( "audio-x-generic" ) );
else
sessionItem->setIcon( 0, QIcon::fromTheme( "application-x-tar" ) );
d->sessions.insert( sessionItem, SessionInfo( lastSession, medium.device() ) );
}
}
if( 0 == lastSession ) {
// the medium item in case we have no session info (will always use the last session)
d->sessions.insert( mediumItem, SessionInfo( 0, medium.device() ) );
}
else {
// we have a session item, there is no need to select the medium as a whole
mediumItem->setFlags( mediumItem->flags() ^ Qt::ItemIsSelectable );
}
mediumItem->setExpanded( true );
}
示例11: addGroup
void LadspaFXSelector::addGroup( QTreeWidget *parent, Tritium::LadspaFXGroup *pGroup )
{
QTreeWidgetItem* pNewItem = new QTreeWidgetItem( parent );
QFont f = pNewItem->font( 0 );
f.setBold( true );
pNewItem->setFont( 0, f );
buildGroup( pNewItem, pGroup );
}
示例12: addToHistory
/**
* Add a single work order to the display. This uses the QUndoCommand text (if it's blank, it uses
* the QAction text). If there is no text, this does nothing.
*
* @param workOrder The work order to display the history for
*/
void HistoryTreeWidget::addToHistory(WorkOrder *workOrder) {
QString data = workOrder->bestText();
connect(workOrder, SIGNAL(destroyed(QObject *)),
this, SLOT(removeFromHistory(QObject *)));
QStringList columnData;
columnData.append(data);
columnData.append("");
columnData.append(workOrder->executionTime().toString());
QTreeWidgetItem *newItem = new QTreeWidgetItem(columnData);
newItem->setData(0, Qt::UserRole, qVariantFromValue(workOrder));
// Do font for save work orders
if (workOrder->createsCleanState()) {
QFont saveFont = newItem->font(0);
saveFont.setBold(true);
saveFont.setItalic(true);
newItem->setFont(0, saveFont);
newItem->setForeground(0, Qt::gray);
}
// Do font for progress text
QFont progressFont = newItem->font(1);
progressFont.setItalic(true);
newItem->setFont(1, progressFont);
newItem->setForeground(1, Qt::gray);
invisibleRootItem()->addChild(newItem);
connect(workOrder, SIGNAL(statusChanged(WorkOrder *)),
this, SLOT(updateStatus(WorkOrder *)));
connect(workOrder, SIGNAL(creatingProgress(WorkOrder *)),
this, SLOT(updateProgressWidgets()));
connect(workOrder, SIGNAL(deletingProgress(WorkOrder *)),
this, SLOT(updateProgressWidgets()));
if (workOrder->progressBar()) {
setItemWidget(newItem, 1, workOrder->progressBar());
}
scrollToItem(newItem);
refit();
}
示例13: QTreeWidget
//----------------------------------------------------------------------------------------
OfsTreeWidget::OfsTreeWidget(QWidget *parent, unsigned int capabilities, std::string initialSelection) : QTreeWidget(parent), mCapabilities(capabilities)
{
mSelected = initialSelection;
setColumnCount(1);
setHeaderHidden(true);
setSelectionMode(QAbstractItemView::SingleSelection);
setSelectionBehavior(QAbstractItemView::SelectItems);
setContextMenuPolicy(Qt::CustomContextMenu);
setDragDropOverwriteMode(false);
if(capabilities & CAP_ALLOW_DROPS)
setDragDropMode(QAbstractItemView::DropOnly);
mUnknownFileIcon = mOgitorMainWindow->mIconProvider.icon(QFileIconProvider::File);
mFile = Ogitors::OgitorsRoot::getSingletonPtr()->GetProjectFile();
QTreeWidgetItem* item = 0;
QTreeWidgetItem* pItem = new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("Project")));
pItem->setIcon(0, mOgitorMainWindow->mIconProvider.icon(QFileIconProvider::Folder));
pItem->setTextColor(0, Qt::black);
QFont fnt = pItem->font(0);
fnt.setBold(true);
pItem->setFont(0, fnt);
pItem->setWhatsThis(0, QString("/"));
addTopLevelItem(pItem);
fillTree(pItem, "/");
if(capabilities & CAP_SHOW_FILES)
fillTreeFiles(pItem, "/");
expandItem(pItem);
if(mSelected == "/")
setItemSelected(pItem, true);
else
{
NameTreeWidgetMap::iterator it = mItemMap.find(mSelected);
if(it != mItemMap.end())
{
clearSelection();
scrollToItem(it->second);
setItemSelected(it->second, true);
}
}
connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(onSelectionChanged()));
if(capabilities & CAP_SHOW_FILES)
{
connect(this, SIGNAL(itemCollapsed( QTreeWidgetItem * )), this, SLOT(onItemCollapsed( QTreeWidgetItem * )));
connect(this, SIGNAL(itemExpanded( QTreeWidgetItem * )), this, SLOT(onItemExpanded( QTreeWidgetItem * )));
}
示例14: showSort
void TreeArea::showSort(int clickedTree){
QTreeWidgetItem* item;
if (clickedTree == TreeArea::clickInSortsTree){
item = this->sortsTree->currentItem();
}
if (clickedTree == TreeArea::clickInGroupsTree){
item = this->groupsTree->currentItem();
}
// Set the item font to normal
QFont f = item->font(0);
f.setItalic(false);
item->setFont(0, f);
// Get the name of the item
QString text = item->text(0);
if (clickedTree == TreeArea::clickInSortsTree){
// Set the normal font for the items related to the same sort in the groupsTree
QList<QTreeWidgetItem*> sortsInTheGroupTree = this->groupsTree->findItems(text, Qt::MatchContains | Qt::MatchRecursive, 0);
for (QTreeWidgetItem* &a: sortsInTheGroupTree){
QFont b = a->font(0);
b.setItalic(false);
a->setFont(0,b);
}
}
if (clickedTree == TreeArea::clickInGroupsTree){
// Set the normal font for the items related to the same sort in the sortsTree
QList<QTreeWidgetItem*> sortsInTheSortsTree = this->sortsTree->findItems(text, Qt::MatchExactly, 0);
for (QTreeWidgetItem* &a: sortsInTheSortsTree){
QFont b = a->font(0);
b.setItalic(false);
a->setFont(0,b);
}
}
// Show the QGraphicsItem representing the sort
this->myPHPtr->getGraphicsScene()->getGSort(text.toStdString())->GSort::show();
std::vector<GActionPtr> allActions = this->myPHPtr->getGraphicsScene()->getActions();
for (GActionPtr &a: allActions){
if (a->getAction()->getSource()->getSort()->getName() == text.toStdString() || a->getAction()->getTarget()->getSort()->getName() == text.toStdString() || a->getAction()->getResult()->getSort()->getName() == text.toStdString()){
if ( (myPHPtr->getGraphicsScene()->getGSort(a->getAction()->getSource()->getSort()->getName())->GSort::isVisible())
&& (myPHPtr->getGraphicsScene()->getGSort(a->getAction()->getTarget()->getSort()->getName())->GSort::isVisible())
&& (myPHPtr->getGraphicsScene()->getGSort(a->getAction()->getResult()->getSort()->getName())->GSort::isVisible()) )
{
a->getDisplayItem()->show();
}
}
}
}
示例15: addPlugins
// public
void PluginsDialog::addPlugins( const PluginsLoader& ploader)
{
const QList<PluginsLoader::PluginMeta>& plugins = ploader.getPlugins();
for ( const PluginsLoader::PluginMeta& pmeta : plugins)
{
QTreeWidgetItem *pluginItem = new QTreeWidgetItem(ui->treeWidget);
pluginItem->setText(0, pmeta.filepath);
QFont font = pluginItem->font(0);
font.setBold(true);
pluginItem->setFont(0, font);
if ( !pmeta.loaded) // Show plugin in red italics if it couldn't be loaded
{
pluginItem->setTextColor(0, QColor::fromRgbF(1,0,0));
QFont font = pluginItem->font(0);
font.setItalic(true);
pluginItem->setFont(0, font);
} // end if
else
{
ui->treeWidget->setItemExpanded(pluginItem, true);
// TODO Add in user selected enabling/disabling of dynamic plugins (requires restart).
//pluginItem->setCheckState(0, Qt::CheckState::Checked);
// Get the names of the available interfaces in this plugin
const QStringList pnames = pmeta.plugin->getInterfaceIds();
for ( const QString& pname : pnames)
{
const QTools::PluginInterface* iface = pmeta.plugin->getInterface(pname);
if (iface)
{
QTreeWidgetItem *iitem = new QTreeWidgetItem(pluginItem);
const QString cname = iface->metaObject()->className();
iitem->setText(0, iface->getDisplayName() + " (" + cname + ")");
iitem->setIcon(0, *iface->getIcon());
QFont font = iitem->font(0);
font.setItalic(true);
iitem->setFont(0, font);
} // end if
} // end foreach
} // end if
} // end foreach
} // end addPlugins