本文整理汇总了C++中QStandardItem::setIcon方法的典型用法代码示例。如果您正苦于以下问题:C++ QStandardItem::setIcon方法的具体用法?C++ QStandardItem::setIcon怎么用?C++ QStandardItem::setIcon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStandardItem
的用法示例。
在下文中一共展示了QStandardItem::setIcon方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: report
QStandardItem* SelfTestDialog::report( ResultType type, const KLocalizedString & summary, const KLocalizedString & details)
{
QStandardItem *item = new QStandardItem( summary.toString() );
switch ( type ) {
case Skip:
item->setIcon( KIcon( QString::fromLatin1( "dialog-ok" ) ) );
break;
case Success:
item->setIcon( KIcon( QString::fromLatin1( "dialog-ok-apply" ) ) );
break;
case Warning:
item->setIcon( KIcon( QString::fromLatin1( "dialog-warning" ) ) );
break;
case Error:
default:
item->setIcon( KIcon( QString::fromLatin1( "dialog-error" ) ) );
}
item->setEditable( false );
item->setWhatsThis( details.toString() );
item->setData( type, ResultTypeRole );
item->setData( summary.toString( 0 ), SummaryRole );
item->setData( details.toString( 0 ), DetailsRole );
mTestModel->appendRow( item );
return item;
}
示例2: showExample
void TreeView::showExample(void)
{
this->setColumn(1, 100,QStringLiteral("GPRS_STRUCT"));
for(int i = 0; i < 10; ++i)
{
QList<QStandardItem *> leve0;
QStandardItem * item = new QStandardItem(QString("GRPS_%0").arg(i));
item->setCheckable(1);//使能复选框
item->setIcon(QIcon(":/image/Aqua Ball.ico"));
leve0.append(item);
mode->appendRow(leve0);
for(int j = 0; j < 5; ++j)
{
QList<QStandardItem *> leve1;
QStandardItem * item = new QStandardItem(QString("Sensor_%0").arg(j));
item->setCheckable(1);//使能复选框
item->setIcon(QIcon(":/image/Aqua Ball Green.ico"));
leve1.append(item);
/* for(int i = 1; i < 4; ++i)
{
QStandardItem * item = new QStandardItem(QString("state_%0").arg(i));
leve1.append(item);
}*/
leve0.at(0)->appendRow(leve1);
}
}
// ui->treeView->setSelectionMode(QAbstractItemView::ExtendedSelection);//设置多选
this->setEditTriggers(0);//取消双击修改
this->setContextMenuPolicy(Qt::CustomContextMenu);//设置treeView右键单击产生相应信号,并设置连接
}
示例3: pathsAdded
void ctkCmdLineModuleExplorerModulesSettings::pathsAdded(const QStringList &paths)
{
// Check the validity of the entries
foreach(const QString& path, paths)
{
ctkCmdLineModuleReference moduleRef = this->ModuleManager->moduleReference(QUrl::fromLocalFile(path));
if (!moduleRef || !moduleRef.xmlValidationErrorString().isEmpty())
{
QStandardItem* item = ui->PathListWidget->item(path);
if (this->WarningIcon.isNull())
{
this->WarningIcon = ctkCmdLineModuleExplorerUtils::createIconOverlay(
item->icon().pixmap(item->icon().availableSizes().front()),
QApplication::style()->standardPixmap(QStyle::SP_MessageBoxWarning));
}
QString toolTip = path + "\n\n" + tr("Warning") + ":\n\n";
if (moduleRef)
{
item->setIcon(this->WarningIcon);
toolTip += moduleRef.xmlValidationErrorString();
}
else if (this->ModulesRegistered)
{
item->setIcon(this->WarningIcon);
toolTip += tr("No XML output available.");
}
else
{
toolTip = path;
}
item->setToolTip(toolTip);
}
}
示例4: dropEvent
void BookmarkList::dropEvent(QDropEvent *event)
{
const QMimeData* data = event->mimeData();
if(data->hasUrls())
{
//TODO: Add insert to the dropped row, except row 0
QStandardItemModel* mod = (QStandardItemModel*)model();
QString path = data->urls()[0].path();
QFileInfo f(path);
if(mod)
{
QList<QStandardItem*> items = mod->findItems(f.fileName());
if(f.isDir() && items.isEmpty())
{
QStandardItem *it = new QStandardItem();
it->setText(f.fileName());
it->setData(path);
#if QT_VERSION >= 0x040600
// Todo: Use a "favorites folder" icon instead
it->setIcon(*globalIcon);
#else
it->setIcon(QIcon(":/images/icons/clip-folder-bookmark.png"));
#endif
it->setDropEnabled(true);
mod->appendRow(it);
emit bookmarkAdded();
}
}
}
event->acceptProposedAction();
}
示例5: addItem
QStandardItem* QgsMilXLibrary::addItem( QStandardItem* parent, const QString& value, const QImage& image, bool isLeaf, const QString& symbolXml, const QString& symbolMilitaryName, int symbolPointCount , bool symbolHasVariablePoints )
{
QIcon icon;
QSize iconSize = isLeaf ? mTreeView->iconSize() : !image.isNull() ? QSize( 32, 32 ) : QSize( 1, 32 );
QImage iconImage( iconSize, QImage::Format_ARGB32 );
iconImage.fill( Qt::transparent );
if ( !image.isNull() )
{
double scale = qMin( 1., image.width() > image.height() ? iconImage.width() / double( image.width() ) : iconImage.height() / double( image.height() ) );
QPainter painter( &iconImage );
painter.setRenderHint( QPainter::SmoothPixmapTransform );
painter.drawImage(
QRectF( 0.5 * ( iconSize.width() - scale * image.width() ), 0.5 * ( iconSize.height() - scale * image.height() ), scale * image.width(), scale * image.height() ),
image );
}
icon = QIcon( QPixmap::fromImage( iconImage ) );
if ( !parent )
{
parent = mGalleryModel->invisibleRootItem();
}
// Create category group item if necessary
if ( !isLeaf )
{
// Don't create subgroups with same text as parent
if ( parent->text() == value )
{
return parent;
}
QStandardItem* groupItem = 0;
for ( int i = 0, n = parent->rowCount(); i < n; ++i )
{
if ( parent->child( i )->text() == value )
{
groupItem = parent->child( i );
break;
}
}
if ( !groupItem )
{
groupItem = new QStandardItem( value );
groupItem->setDragEnabled( false );
parent->setChild( parent->rowCount(), groupItem );
groupItem->setIcon( icon );
}
return groupItem;
}
else
{
QStandardItem* item = new QStandardItem( QString( "%1" ).arg( symbolMilitaryName ) );
parent->setChild( parent->rowCount(), item );
item->setData( symbolXml, SymbolXmlRole );
item->setData( symbolMilitaryName, SymbolMilitaryNameRole );
item->setData( symbolPointCount, SymbolPointCountRole );
item->setData( symbolHasVariablePoints, SymbolVariablePointsRole );
item->setToolTip( item->text() );
item->setIcon( icon );
return item;
}
}
示例6: handleSourceChanged
void Player::handleSourceChanged (const Phonon::MediaSource& source)
{
for (int i = 0; i < QueueModel_->rowCount (); ++i)
{
QStandardItem *item = QueueModel_->item (i);
if (source == *item->data (SourceRole).value<MediaSource*> ())
item->setIcon (Core::Instance ().GetCoreProxy ()->GetIcon ("lmp_play"));
else
item->setIcon (QIcon ());
}
}
示例7: 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;
}
示例8: browseAllGenres
void SingleGenreView::browseAllGenres(uint browseId, int remainingCount, uint, QString objectId, GHashTable* metadata, QString error)
{
if (browseId != browseGenreId) return;
if (metadata != NULL) {
QString title;
int songCount = -1;
int albumCount = -1;
GValue *v;
QStandardItem *item = new QStandardItem();
v = mafw_metadata_first(metadata, MAFW_METADATA_KEY_TITLE);
title = v ? QString::fromUtf8(g_value_get_string(v)) : tr("(unknown artist)");
v = mafw_metadata_first(metadata, MAFW_METADATA_KEY_CHILDCOUNT_1);
albumCount = v ? g_value_get_int (v) : -1;
v = mafw_metadata_first(metadata, MAFW_METADATA_KEY_CHILDCOUNT_2);
songCount = v ? g_value_get_int (v) : -1;
v = mafw_metadata_first(metadata, MAFW_METADATA_KEY_ALBUM_ART_SMALL_URI);
if (v != NULL) {
const gchar* file_uri = g_value_get_string(v);
gchar* filename = NULL;
if (file_uri != NULL && (filename = g_filename_from_uri(file_uri, NULL, NULL)) != NULL)
item->setIcon(QIcon(QString::fromUtf8(filename)));
} else {
item->setIcon(QIcon::fromTheme(defaultAlbumIcon));
}
if (title.isEmpty()) title = tr("(unknown artist)");
item->setText(title);
item->setData(songCount, UserRoleSongCount);
item->setData(albumCount, UserRoleAlbumCount);
item->setData(objectId, UserRoleObjectID);
objectModel->appendRow(item);
visibleSongs += songCount; updateSongCount();
}
if (!error.isEmpty())
qDebug() << error;
if (remainingCount == 0) {
disconnect(mafwTrackerSource, SIGNAL(browseResult(uint,int,uint,QString,GHashTable*,QString)),
this, SLOT(browseAllGenres(uint,int,uint,QString,GHashTable*,QString)));
setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
}
示例9: fillingModel
void Priorities::fillingModel(QSqlQuery &stored)
{
m_model->clear();
m_model->insertColumns(0, MODEL_COLUMN_COUNT);
m_model->insertRows(0, stored.numRowsAffected());
unsigned j(0);
QString m_item;
unsigned ncols = stored.record().count();
#ifndef QT_NO_CURSOR
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
#endif
while(stored.next())
{
for (unsigned i = 0; i != ncols; ++i){
if (stored.value(i).toDateTime().isValid()) {
m_item = stored.value(i).toDateTime().toString("yyyy-MM-dd hh:mm:ss");
} else {
m_item = stored.value(i).toString();
}
QStandardItem *item = new QStandardItem(m_item.trimmed());
if (i == 1){
item->setIcon(QIcon("data/picture/sidebar/priority.ico"));
} else
if (i == 5){
QStandardItem *item = new QStandardItem();
unsigned m_value = stored.record().field("pt_level").value().toUInt();
switch (m_value) {
case 0:
item->setIcon(QIcon("data/picture/additionally/red.ico"));
break;
case 1:
item->setIcon(QIcon("data/picture/additionally/yellow.ico"));
break;
case 2:
item->setIcon(QIcon("data/picture/additionally/green.ico"));
break;
default:
break;
}
m_model->setItem(j, ncols, item);
}
m_model->setItem(j, i, item);
}
++j;
}
#ifndef QT_NO_CURSOR
QApplication::restoreOverrideCursor();
#endif
}
示例10: insertItems
void CommunicationTree::insertItems(const int socketDescriptor, const QString & ip, const quint16 port, int linkIndex) {
// QList<QStandardItem*> list;
// list.append(new QStandardItem(QString(socketDescriptor)));
// list.append(new QStandardItem(ip));
// list.append(new QStandardItem(QString(port)));
// QString channelInfo = QStringLiteral("%1(%2):%3").arg(ip).arg(socketDescriptor).arg(port);
QStandardItem *item = new QStandardItem(QStringLiteral("%1(%2)").arg(ip).arg(socketDescriptor));
if(linkIndex == LINKINFO_CONNECTED)
item->setIcon(QIcon(":/res/images/256/ligthbulb_on.png"));
else
item->setIcon(QIcon(":/res/images/256/ligthbulb_off.png"));
communication->appendRow(item);
}
示例11: RecursivelySetIcons
void PlaylistListContainer::RecursivelySetIcons(QStandardItem* parent) const {
for (int i = 0; i < parent->rowCount(); ++i) {
QStandardItem* child = parent->child(i);
switch (child->data(PlaylistListModel::Role_Type).toInt()) {
case PlaylistListModel::Type_Folder:
child->setIcon(model_->folder_icon());
RecursivelySetIcons(child);
break;
case PlaylistListModel::Type_Playlist:
child->setIcon(model_->playlist_icon());
break;
}
}
}
示例12: dir
QgsSvgSelectorGroupsModel::QgsSvgSelectorGroupsModel( QObject* parent )
: QStandardItemModel( parent )
{
QStringList svgPaths = QgsApplication::svgPaths();
QStandardItem *parentItem = invisibleRootItem();
for ( int i = 0; i < svgPaths.size(); i++ )
{
QDir dir( svgPaths[i] );
QStandardItem *baseGroup;
if ( dir.path().contains( QgsApplication::pkgDataPath() ) )
{
baseGroup = new QStandardItem( tr( "App Symbols" ) );
}
else if ( dir.path().contains( QgsApplication::qgisSettingsDirPath() ) )
{
baseGroup = new QStandardItem( tr( "User Symbols" ) );
}
else
{
baseGroup = new QStandardItem( dir.dirName() );
}
baseGroup->setData( QVariant( svgPaths[i] ) );
baseGroup->setEditable( false );
baseGroup->setCheckable( false );
baseGroup->setIcon( QgsApplication::style()->standardIcon( QStyle::SP_DirIcon ) );
baseGroup->setToolTip( dir.path() );
parentItem->appendRow( baseGroup );
createTree( baseGroup );
QgsDebugMsg( QString( "SVG base path %1: %2" ).arg( i ).arg( baseGroup->data().toString() ) );
}
}
示例13: populateSymbols
void QgsStyleManagerDialog::populateSymbols( const QStringList& symbolNames, bool check )
{
QStandardItemModel* model = qobject_cast<QStandardItemModel*>( listItems->model() );
model->clear();
int type = currentItemType();
for ( int i = 0; i < symbolNames.count(); ++i )
{
QString name = symbolNames[i];
QgsSymbol* symbol = mStyle->symbol( name );
if ( symbol && symbol->type() == type )
{
QStandardItem* item = new QStandardItem( name );
QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( symbol, listItems->iconSize() );
item->setIcon( icon );
item->setData( name ); // used to find out original name when user edited the name
item->setCheckable( check );
item->setToolTip( name );
// add to model
model->appendRow( item );
}
delete symbol;
}
selectedSymbolsChanged( QItemSelection(), QItemSelection() );
symbolSelected( listItems->currentIndex() );
}
示例14: on_bSearch_clicked
void Window::on_bSearch_clicked()
{
searchmodel->clear();
QString directory_path = ui->directory->text();
QString searchtext = ui->searchtext->text();
QDirIterator directory_indexer(directory_path, QDir::Files | QDir::NoSymLinks, QDirIterator::Subdirectories);
uint count = 0;
QFileIconProvider iconprovider;
while(directory_indexer.hasNext())
{
directory_indexer.next();
QString path = directory_indexer.fileInfo().absoluteFilePath();
if(QFileInfo(path).fileName().contains(searchtext))
{
QStandardItem *item = new QStandardItem(path);
item->setIcon(iconprovider.icon(path));
searchmodel->setItem(count, item);
count++;
}
}
}
示例15: fillTaskModel
void CTaskType::fillTaskModel(QSqlQuery &stored)
{
modelTask->removeRows(0, modelTask->rowCount(QModelIndex()), QModelIndex());
modelTask->insertRows(stored.numRowsAffected(), 0);
#ifndef QT_NO_CURSOR
QApplication::setOverrideCursor(QCursor(QPixmap("data/picture/additionally/wait.png")));
#endif
QString it;
int ncols = stored.record().count();
int row(0);
while(stored.next())
{
for (int i = 0; i != ncols; ++i){
it = stored.value(i).toString();
QStandardItem *item = new QStandardItem(it);
if (i == stored.record().indexOf("tt_name")){
item->setIcon(QIcon("data/picture/sidebar/tasktype.ico"));
}
modelTask->setItem(row ,i, item);
}
++row;
}
#ifndef QT_NO_CURSOR
QApplication::restoreOverrideCursor();
#endif
}