本文整理汇总了C++中QTreeWidgetItem::icon方法的典型用法代码示例。如果您正苦于以下问题:C++ QTreeWidgetItem::icon方法的具体用法?C++ QTreeWidgetItem::icon怎么用?C++ QTreeWidgetItem::icon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTreeWidgetItem
的用法示例。
在下文中一共展示了QTreeWidgetItem::icon方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copyContents
void TreeWidgetEditor::copyContents(QTreeWidget *sourceWidget, QTreeWidget *destWidget)
{
destWidget->clear();
int colCount = sourceWidget->columnCount();
destWidget->setColumnCount(colCount);
QTreeWidgetItem *origHeaderItem = sourceWidget->headerItem();
QTreeWidgetItem *headerItem = destWidget->headerItem();
for (int col = 0; col < colCount; col++) {
headerItem->setText(col, origHeaderItem->text(col));
headerItem->setIcon(col, origHeaderItem->icon(col));
}
if (!colCount)
return;
QTreeWidgetItem *lastItem = 0;
for (int i = 0; i < sourceWidget->topLevelItemCount(); i++) {
QTreeWidgetItem *origItem = sourceWidget->topLevelItem(i);
lastItem = new QTreeWidgetItem(destWidget);
lastItem->setFlags(lastItem->flags() | Qt::ItemIsEditable);
for (int j = 0; j < colCount; j++) {
lastItem->setText(j, origItem->text(j));
lastItem->setIcon(j, origItem->icon(j));
}
destWidget->setItemExpanded(lastItem, true);
copyContents(origItem, lastItem);
}
}
示例2: moveColumnsRight
void TreeWidgetEditor::moveColumnsRight(int fromColumn, int toColumn)
{
if (fromColumn >= toColumn)
return;
QTreeWidgetItem *headerItem = ui.treeWidget->headerItem();
QString text = headerItem->text(fromColumn);
QIcon icon = headerItem->icon(fromColumn);
for (int i = fromColumn; i < toColumn; i++) {
headerItem->setText(i, headerItem->text(i + 1));
headerItem->setIcon(i, headerItem->icon(i + 1));
}
headerItem->setText(toColumn, text);
headerItem->setIcon(toColumn, icon);
QQueue<QTreeWidgetItem *> pendingQueue;
for (int i = 0; i < ui.treeWidget->topLevelItemCount(); i++)
pendingQueue.enqueue(ui.treeWidget->topLevelItem(i));
while (!pendingQueue.isEmpty()) {
QTreeWidgetItem *item = pendingQueue.dequeue();
for (int i = 0; i < item->childCount(); i++)
pendingQueue.enqueue(item->child(i));
QString text = item->text(fromColumn);
QIcon icon = item->icon(fromColumn);
for (int i = fromColumn; i < toColumn; i++) {
item->setText(i, item->text(i + 1));
item->setIcon(i, item->icon(i + 1));
}
item->setText(toColumn, text);
item->setIcon(toColumn, icon);
}
}
示例3: icon
QIcon QTreeWidgetItemProto::icon(int column) const
{
QTreeWidgetItem *item = qscriptvalue_cast<QTreeWidgetItem*>(thisObject());
if (item)
return item->icon(column);
return QIcon();
}
示例4: on_previewPixmapItemButton_clicked
void TreeWidgetEditor::on_previewPixmapItemButton_clicked()
{
QTreeWidgetItem *curItem = ui.treeWidget->currentItem();
if (!curItem)
return;
if (!ui.listWidget->currentItem())
return;
int currentRow = ui.listWidget->currentRow();
FindIconDialog dialog(m_form, this);
QString file_path;
QString qrc_path;
QIcon icon = curItem->icon(currentRow);
if (!icon.isNull()) {
file_path = m_form->core()->iconCache()->iconToFilePath(icon);
qrc_path = m_form->core()->iconCache()->iconToQrcPath(icon);
}
dialog.setPaths(qrc_path, file_path);
if (dialog.exec()) {
file_path = dialog.filePath();
qrc_path = dialog.qrcPath();
if (!file_path.isEmpty()) {
icon = m_form->core()->iconCache()->nameToIcon(file_path, qrc_path);
curItem->setIcon(currentRow, icon);
ui.previewPixmapItemButton->setIcon(icon);
ui.deletePixmapItemButton->setEnabled(!icon.isNull());
}
}
}
示例5: fillContentsFromTreeWidget
void TreeWidgetEditor::fillContentsFromTreeWidget(QTreeWidget *treeWidget)
{
m_updating = true;
copyContents(treeWidget, ui.treeWidget);
ui.listWidget->clear();
QTreeWidgetItem *headerItem = ui.treeWidget->headerItem();
int colCount = ui.treeWidget->columnCount();
for (int col = 0; col < colCount; col++) {
QListWidgetItem *item = new QListWidgetItem(ui.listWidget);
item->setFlags(item->flags() | Qt::ItemIsEditable);
item->setText(headerItem->text(col));
item->setIcon(headerItem->icon(col));
item->setData(QAbstractFormBuilder::resourceRole(), headerItem->data(col, QAbstractFormBuilder::resourceRole()));
}
if (colCount > 0) {
ui.listWidget->setCurrentRow(0);
if (ui.treeWidget->topLevelItemCount() > 0)
ui.treeWidget->setCurrentItem(ui.treeWidget->topLevelItem(0));
}
m_updating = false;
updateEditor();
}
示例6: getItemColor
QColor GTUtilsAnnotHighlightingTreeView::getItemColor(HI::GUITestOpStatus &os, const QString &itemName){
QTreeWidgetItem* item = findItem(os, itemName);
QIcon icon = item->icon(1);
QPixmap pixmap = icon.pixmap(5, 5);
QImage img = pixmap.toImage();
QRgb rgb = img.pixel(QPoint(2,2));
QColor result = QColor(rgb);
return result;
}
示例7: moveColumnsRight
void TreeWidgetEditor::moveColumnsRight(int fromColumn, int toColumn)
{
if (fromColumn >= toColumn)
return;
QTreeWidgetItem *headerItem = ui.treeWidget->headerItem();
const QString text = headerItem->text(fromColumn);
const QIcon icon = headerItem->icon(fromColumn);
const QVariant data = headerItem->data(fromColumn, QAbstractFormBuilder::resourceRole());
for (int i = fromColumn; i < toColumn; i++) {
headerItem->setText(i, headerItem->text(i + 1));
headerItem->setIcon(i, headerItem->icon(i + 1));
headerItem->setData(i, QAbstractFormBuilder::resourceRole(), headerItem->data(i + 1, QAbstractFormBuilder::resourceRole()));
}
headerItem->setText(toColumn, text);
headerItem->setIcon(toColumn, icon);
headerItem->setData(toColumn, QAbstractFormBuilder::resourceRole(), data);
QQueue<QTreeWidgetItem *> pendingQueue;
for (int i = 0; i < ui.treeWidget->topLevelItemCount(); i++)
pendingQueue.enqueue(ui.treeWidget->topLevelItem(i));
while (!pendingQueue.isEmpty()) {
QTreeWidgetItem *item = pendingQueue.dequeue();
for (int i = 0; i < item->childCount(); i++)
pendingQueue.enqueue(item->child(i));
const QString text = item->text(fromColumn);
const QIcon icon = item->icon(fromColumn);
const QVariant data = item->data(fromColumn, QAbstractFormBuilder::resourceRole());
for (int i = fromColumn; i < toColumn; i++) {
item->setText(i, item->text(i + 1));
item->setIcon(i, item->icon(i + 1));
item->setData(i, QAbstractFormBuilder::resourceRole(), item->data(i + 1, QAbstractFormBuilder::resourceRole()));
}
item->setText(toColumn, text);
item->setIcon(toColumn, icon);
item->setData(toColumn, QAbstractFormBuilder::resourceRole(), icon);
}
}
示例8: data
QVariant DbStructureModel::data(const QModelIndex& index, int role) const
{
if(!index.isValid())
return QVariant();
// Get the item the index points at
QTreeWidgetItem* item = static_cast<QTreeWidgetItem*>(index.internalPointer());
// Depending on the role either return the text or the icon
if(role == Qt::DisplayRole)
return item->text(index.column());
else if(role == Qt::DecorationRole)
return item->icon(index.column());
else
return QVariant();
}
示例9: data
QVariant DbStructureModel::data(const QModelIndex& index, int role) const
{
if(!index.isValid())
return QVariant();
// Get the item the index points at
QTreeWidgetItem* item = static_cast<QTreeWidgetItem*>(index.internalPointer());
// Depending on the role either return the text or the icon
if(role == Qt::DisplayRole)
return Settings::getSettingsValue("db", "hideschemalinebreaks").toBool() ? item->text(index.column()).replace("\n", " ").simplified() : item->text(index.column());
else if(role == Qt::ToolTipRole)
return item->text(index.column()); // Don't modify the text when it's supposed to be shown in a tooltip
else if(role == Qt::DecorationRole)
return item->icon(index.column());
else
return QVariant();
}
示例10: displayCurrent
bool DisassembleWidget::displayCurrent()
{
if(address_ < lower_ || address_ > upper_) return false;
bool bFound=false;
for (int line=0; line < m_treeWidget->topLevelItemCount(); line++)
{
QTreeWidgetItem* item = m_treeWidget->topLevelItem(line);
unsigned long address = strtoul(item->text(Address).toLatin1(), 0, 0);
if (address == address_)
{
// put cursor at start of line and highlight the line
m_treeWidget->setCurrentItem(item);
item->setIcon(Icon, icon_);
bFound = true; // need to process all items to clear icons
}
else if(!item->icon(Icon).isNull()) item->setIcon(Icon, QIcon());
}
return bFound;
}
示例11: displayCurrent
bool DisassembleWidget::displayCurrent()
{
if(address_ < lower_ || address_ > upper_) return false;
bool bFound=false;
for (int line=0; line < m_disassembleWindow->topLevelItemCount(); line++)
{
QTreeWidgetItem* item = m_disassembleWindow->topLevelItem(line);
unsigned long address = item->text(Address).toULong(&ok,16);
if (address == address_)
{
// put cursor at start of line and highlight the line
m_disassembleWindow->setCurrentItem(item);
static const QIcon icon = QIcon::fromTheme(QStringLiteral("go-next"));
item->setIcon(Icon, icon);
bFound = true; // need to process all items to clear icons
}
else if(!item->icon(Icon).isNull()) item->setIcon(Icon, QIcon());
}
return bFound;
}
示例12: data
QVariant DbStructureModel::data(const QModelIndex& index, int role) const
{
if(!index.isValid())
return QVariant();
// Get the item the index points at
QTreeWidgetItem* item = static_cast<QTreeWidgetItem*>(index.internalPointer());
// Depending on the role either return the text or the icon
switch(role)
{
case Qt::DisplayRole:
// For the display role and the browsable branch of the tree we want to show the column name including the schema name if necessary (i.e.
// for schemata != "main"). For the normal structure branch of the tree we don't want to add the schema name because it's already obvious from
// the position of the item in the tree.
if(index.column() == ColumnName && item->parent() == browsablesRootItem)
return sqlb::ObjectIdentifier(item->text(ColumnSchema), item->text(ColumnName)).toDisplayString();
else
return Settings::getValue("db", "hideschemalinebreaks").toBool() ? item->text(index.column()).replace("\n", " ").simplified() : item->text(index.column());
case Qt::EditRole:
return item->text(index.column());
case Qt::ToolTipRole: {
// Show the original text but limited, when it's supposed to be shown in a tooltip
QString text = item->text(index.column());
if (text.length() > 512) {
text.truncate(509);
text.append("...");
}
return text;
}
case Qt::DecorationRole:
return item->icon(index.column());
default:
return QVariant();
}
}
示例13: on_moveActionRightButton_clicked
/** Adds a new action */
void DlgCustomToolbars::on_moveActionRightButton_clicked()
{
QTreeWidgetItem* item = commandTreeWidget->currentItem();
if (item) {
QTreeWidgetItem* current = toolbarTreeWidget->currentItem();
if (!current)
current = toolbarTreeWidget->topLevelItem(0);
else if (current->parent())
current = current->parent();
if (current && !current->parent()) {
QTreeWidgetItem* copy = new QTreeWidgetItem(current);
copy->setText(0, item->text(1));
copy->setIcon(0, item->icon(0));
QByteArray data = item->data(1, Qt::UserRole).toByteArray();
copy->setData(0, Qt::UserRole, data);
copy->setSizeHint(0, QSize(32, 32));
addCustomCommand(current->text(0), data);
}
}
QVariant data = workbenchBox->itemData(workbenchBox->currentIndex(), Qt::UserRole);
QString workbench = data.toString();
exportCustomToolbars(workbench.toLatin1());
}
示例14: mousePressEvent
//.........这里部分代码省略.........
#ifdef Q_OS_UNIX
if (!QFile::exists("/usr/bin/mypaint"))
myPaintEdit->setDisabled(true);
#else
myPaintEdit->setDisabled(true);
#endif
menu->addAction(myPaintEdit);
}
if (!isSound && !isNative) {
QAction *clone = new QAction(tr("Clone"), this);
connect(clone, SIGNAL(triggered()), this, SLOT(cloneItem()));
menu->addAction(clone);
}
QAction *exportObject = new QAction(tr("Export"), this);
connect(exportObject, SIGNAL(triggered()), this, SLOT(exportItem()));
QAction *rename = new QAction(tr("Rename"), this);
connect(rename, SIGNAL(triggered()), this, SLOT(renameItem()));
QAction *remove = new QAction(tr("Delete"), this);
connect(remove, SIGNAL(triggered()), this, SIGNAL(itemRemoved()));
menu->addAction(exportObject);
menu->addAction(rename);
menu->addAction(remove);
menu->addSeparator();
#ifdef Q_OS_UNIX
if (!isSound) {
if (QFile::exists("/usr/bin/gimp") || QFile::exists("/usr/bin/krita") || QFile::exists("/usr/bin/mypaint")) {
QAction *raster = new QAction(tr("Create new raster item"), this);
connect(raster, SIGNAL(triggered()), this, SLOT(createNewRaster()));
menu->addAction(raster);
}
if (QFile::exists("/usr/bin/inkscape")) {
QAction *svg = new QAction(tr("Create new svg item"), this);
connect(svg, SIGNAL(triggered()), this, SLOT(createNewSVG()));
menu->addAction(svg);
}
}
#endif
}
menu->exec(event->globalPos());
} else if (event->buttons() == Qt::LeftButton) {
// SQA: This code doesn't work well at all. Reengineering is urgently required right here!
// If the node has a parent, get the parent's name
QTreeWidgetItem *top = item->parent();
if (top)
parentNode = top->text(1);
// For directories, get the children
nodeChildren.clear();
if (item->text(2).length()==0 && item->childCount() > 0) {
for (int i=0;i<item->childCount();i++) {
QTreeWidgetItem *node = item->child(i);
nodeChildren << node;
}
}
QPixmap pixmap = item->icon(0).pixmap(15, 15);
QByteArray itemData;
QDataStream dataStream(&itemData, QIODevice::WriteOnly);
dataStream << pixmap << item->text(1) << item->text(2) << item->text(3);
QMimeData *mimeData = new QMimeData;
mimeData->setData("application/x-dnditemdata", itemData);
QDrag *drag = new QDrag(this);
drag->setMimeData(mimeData);
drag->setPixmap(pixmap);
if (drag->start(Qt::MoveAction) == Qt::MoveAction)
delete takeTopLevelItem(indexOfTopLevelItem(item));
}
} else {
if (event->buttons() == Qt::RightButton) {
QMenu *menu = new QMenu(tr("Options"));
#ifdef Q_OS_UNIX
if (QFile::exists("/usr/bin/gimp") || QFile::exists("/usr/bin/krita") || QFile::exists("/usr/bin/mypaint")) {
QAction *raster = new QAction(tr("Create new raster item"), this);
connect(raster, SIGNAL(triggered()), this, SLOT(createNewRaster()));
menu->addAction(raster);
}
if (QFile::exists("/usr/bin/inkscape")) {
QAction *svg = new QAction(tr("Create new svg item"), this);
connect(svg, SIGNAL(triggered()), this, SLOT(createNewSVG()));
menu->addAction(svg);
}
#endif
menu->exec(event->globalPos());
}
}
}
示例15: initList
//.........这里部分代码省略.........
}
custom = findFolder(i18nc("Folder Name", "Custom"));
if (custom == NULL) {
custom = new QTreeWidgetItem((QTreeWidget*)0, QStringList(i18nc("Folder Name", "Custom")));
custom->setData(0, TypeRole, QString::number((int) EffectsList::EFFECT_FOLDER));
custom->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
insertTopLevelItem(0, custom);
}
}
//insertTopLevelItems(0, folders);
if (transitionMode) {
loadEffects(&MainWindow::transitions, misc, &folders, EffectsList::TRANSITION_TYPE, current, &found);
}
else {
loadEffects(&MainWindow::videoEffects, misc, &folders, EffectsList::EFFECT_VIDEO, current, &found);
loadEffects(&MainWindow::audioEffects, audio, &folders, EffectsList::EFFECT_AUDIO, current, &found);
loadEffects(&MainWindow::customEffects, custom, static_cast<QList<QTreeWidgetItem *> *>(0), EffectsList::EFFECT_CUSTOM, current, &found);
if (!found && !currentFolder.isEmpty()) {
// previously selected effect was removed, focus on its parent folder
for (int i = 0; i < topLevelItemCount(); ++i) {
if (topLevelItem(i)->text(0) == currentFolder) {
setCurrentItem(topLevelItem(i));
break;
}
}
}
}
setSortingEnabled(true);
sortByColumn(0, Qt::AscendingOrder);
// populate effects menu
QMenu *sub1 = NULL;
QMenu *sub2 = NULL;
QMenu *sub3 = NULL;
QMenu *sub4 = NULL;
for (int i = 0; i < topLevelItemCount(); ++i) {
if (topLevelItem(i)->data(0, TypeRole) == EffectsList::TRANSITION_TYPE) {
QTreeWidgetItem *item = topLevelItem(i);
QAction *a = new QAction(item->icon(0), item->text(0), effectsMenu);
QStringList data = item->data(0, IdRole).toStringList();
QString id = data.at(1);
if (id.isEmpty()) id = data.at(0);
a->setData(data);
a->setIconVisibleInMenu(false);
effectsMenu->addAction(a);
effectActions->addAction("transition_" + id, a);
continue;
}
if (!topLevelItem(i)->childCount())
continue;
QMenu *sub = new QMenu(topLevelItem(i)->text(0), effectsMenu);
effectsMenu->addMenu(sub);
int effectsInCategory = topLevelItem(i)->childCount();
bool hasSubCategories = false;
if (effectsInCategory > 60) {
// create subcategories if there are too many effects
hasSubCategories = true;
sub1 = new QMenu(i18nc("menu name for effects names between these 2 letters", "0 - F"), sub);
sub->addMenu(sub1);
sub2 = new QMenu(i18nc("menu name for effects names between these 2 letters", "G - L"), sub);
sub->addMenu(sub2);
sub3 = new QMenu(i18nc("menu name for effects names between these 2 letters", "M - R"), sub);
sub->addMenu(sub3);
sub4 = new QMenu(i18nc("menu name for effects names between these 2 letters", "S - Z"), sub);
sub->addMenu(sub4);
}
for (int j = 0; j < effectsInCategory; ++j) {
QTreeWidgetItem *item = topLevelItem(i)->child(j);
QAction *a = new QAction(item->icon(0), item->text(0), sub);
QStringList data = item->data(0, IdRole).toStringList();
QString id = data.at(1);
if (id.isEmpty()) id = data.at(0);
a->setData(data);
a->setIconVisibleInMenu(false);
if (hasSubCategories) {
// put action in sub category
QRegExp rx("^[s-z].+");
if (rx.exactMatch(item->text(0).toLower())) {
sub4->addAction(a);
} else {
rx.setPattern(QStringLiteral("^[m-r].+"));
if (rx.exactMatch(item->text(0).toLower())) {
sub3->addAction(a);
}
else {
rx.setPattern(QStringLiteral("^[g-l].+"));
if (rx.exactMatch(item->text(0).toLower())) {
sub2->addAction(a);
}
else sub1->addAction(a);
}
}
}
else sub->addAction(a);
effectActions->addAction("video_effect_" + id, a);
}
}
}