当前位置: 首页>>代码示例>>C++>>正文


C++ QTreeWidgetItem::setBackground方法代码示例

本文整理汇总了C++中QTreeWidgetItem::setBackground方法的典型用法代码示例。如果您正苦于以下问题:C++ QTreeWidgetItem::setBackground方法的具体用法?C++ QTreeWidgetItem::setBackground怎么用?C++ QTreeWidgetItem::setBackground使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QTreeWidgetItem的用法示例。


在下文中一共展示了QTreeWidgetItem::setBackground方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: updateWidgets

void ProfileDialog::updateWidgets()
{
    QTreeWidgetItem *item = pd_ui_->profileTreeWidget->currentItem();
    bool enable_new = false;
    bool enable_del = false;
    bool enable_copy = false;
    bool enable_ok = true;
    profile_def *current_profile = NULL;

    if (item) {
        current_profile = (profile_def *) item->data(0, Qt::UserRole).value<GList *>()->data;
        enable_new = true;
        enable_copy = true;
        if (!current_profile->is_global && current_profile->status != PROF_STAT_DEFAULT) {
            enable_del = true;
        }
    }

    if (current_profile) {
        QString profile_path = current_profile->is_global ? get_global_profiles_dir() : get_profiles_dir();
        if (current_profile->status != PROF_STAT_DEFAULT) {
            profile_path.append(QDir::separator()).append(current_profile->name);
        }
        pd_ui_->pathLabel->setText(profile_path);
        pd_ui_->pathLabel->setUrl(QUrl::fromLocalFile(profile_path).toString());
        pd_ui_->pathLabel->setToolTip(tr("Go to") + profile_path);
        pd_ui_->pathLabel->setEnabled(true);
    } else {
        pd_ui_->pathLabel->clear();
    }

    if (pd_ui_->profileTreeWidget->topLevelItemCount() > 0) {
        profile_def *profile;
        for (int i = 0; i < pd_ui_->profileTreeWidget->topLevelItemCount(); i++) {
            item = pd_ui_->profileTreeWidget->topLevelItem(i);
            profile = (profile_def *) item->data(0, Qt::UserRole).value<GList *>()->data;
            if (profile->is_global) continue;
            if (current_profile && !current_profile->is_global && profile != current_profile && strcmp(profile->name, current_profile->name) == 0) {
                item->setToolTip(0, tr("A profile already exists with that name."));
                item->setBackground(0, ColorUtils::fromColorT(&prefs.gui_text_invalid));
                enable_ok = false;
            } else {
                item->setBackground(0, QBrush());
            }
        }
    }

    pd_ui_->profileTreeWidget->resizeColumnToContents(0);
    pd_ui_->newToolButton->setEnabled(enable_new);
    pd_ui_->deleteToolButton->setEnabled(enable_del);
    pd_ui_->copyToolButton->setEnabled(enable_copy);
    ok_button_->setEnabled(enable_ok);
}
开发者ID:koyeen,项目名称:wireshark,代码行数:53,代码来源:profile_dialog.cpp

示例2: addItem

void DiagramToolBox::addItem(DrawingItem* item, const QString& section, const QString& text,
	const QString& iconPath)
{
	if (item)
	{
		QTreeWidgetItem* newItem = nullptr;
		QTreeWidgetItem* sectionItem = nullptr;

		for(int i = 0; !sectionItem && i < mTreeWidget->topLevelItemCount(); i++)
		{
			if (mTreeWidget->topLevelItem(i)->text(0) == section)
				sectionItem = mTreeWidget->topLevelItem(i);
		}

		if (!sectionItem)
		{
			sectionItem = new QTreeWidgetItem();
			sectionItem->setText(0, section);
			sectionItem->setBackground(0, palette().brush(QPalette::Button));
			mTreeWidget->addTopLevelItem(sectionItem);
		}

		newItem = new QTreeWidgetItem(sectionItem);
		newItem->setText(0, text);
		if (!iconPath.isEmpty()) newItem->setIcon(0, QIcon(iconPath));

		QAction* newAction = createAction(text, iconPath, "", item->uniqueKey());
		mItemActions[newItem] = newAction;
	}
}
开发者ID:jaallen85,项目名称:jade-legacy,代码行数:30,代码来源:DiagramToolBox.cpp

示例3: addColoringRule

void ColoringRulesDialog::addColoringRule(bool disabled, QString name, QString filter, QColor foreground, QColor background, bool start_editing, bool at_top)
{
    QTreeWidgetItem *ti = new QTreeWidgetItem();

    ti->setFlags(ti->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsEditable);
    ti->setFlags(ti->flags() & ~(Qt::ItemIsDropEnabled));
    ti->setCheckState(name_col_, disabled ? Qt::Unchecked : Qt::Checked);
    ti->setText(name_col_, name);
    ti->setText(filter_col_, filter);

    for (int i = 0; i < ui->coloringRulesTreeWidget->columnCount(); i++) {
        ti->setForeground(i, foreground);
        ti->setBackground(i, background);
    }

    if (at_top) {
        ui->coloringRulesTreeWidget->insertTopLevelItem(0, ti);
    } else {
        ui->coloringRulesTreeWidget->addTopLevelItem(ti);
    }

    if (start_editing) {
        ui->coloringRulesTreeWidget->setCurrentItem(ti);
        updateWidgets();
        ui->coloringRulesTreeWidget->editItem(ti, filter_col_);
    }
}
开发者ID:crondaemon,项目名称:wireshark,代码行数:27,代码来源:coloring_rules_dialog.cpp

示例4: clearHovers

void RDTreeWidget::clearHovers(QTreeWidgetItem *root, QTreeWidgetItem *exception)
{
  for(int i = 0; i < root->childCount(); i++)
  {
    QTreeWidgetItem *n = root->child(i);

    if(n == exception)
      continue;

    clearHovers(n, exception);

    QVariant original = n->data(m_hoverColumn, backupNormalIconRole);

    if(original.isValid())
    {
      QVariant icon = n->data(m_hoverColumn, Qt::DecorationRole);

      n->setData(m_hoverColumn, hoverIconRole, icon);
      n->setData(m_hoverColumn, Qt::DecorationRole, original);
      n->setData(m_hoverColumn, backupNormalIconRole, QVariant());
    }

    original = n->data(m_hoverColumn, backupBackColourRole);

    if(original.isValid())
    {
      QBrush orig = original.value<QBrush>();
      for(int c = 0; c < n->columnCount(); c++)
        n->setBackground(c, orig);
      n->setData(m_hoverColumn, backupBackColourRole, QVariant());
    }
  }
}
开发者ID:gwihlidal,项目名称:renderdoc,代码行数:33,代码来源:RDTreeWidget.cpp

示例5: on_mAddEntryButton_clicked

void QgsSingleBandPseudoColorRendererWidget::on_mAddEntryButton_clicked()
{
  QTreeWidgetItem* newItem = new QTreeWidgetItem( mColormapTreeWidget );
  newItem->setText( 0, "0.0" );
  newItem->setBackground( 1, QBrush( QColor( Qt::magenta ) ) );
  newItem->setText( 2, tr( "Custom color map entry" ) );
}
开发者ID:stevenmizuno,项目名称:QGIS,代码行数:7,代码来源:qgssinglebandpseudocolorrendererwidget.cpp

示例6: on_mAddClassButton_clicked

void QgsRasterTerrainAnalysisDialog::on_mAddClassButton_clicked()
{
  //add class which can be edited by the user later
  QTreeWidgetItem* newItem = new QTreeWidgetItem();
  newItem->setText( 0, "0.00" );
  newItem->setText( 1, "0.00" );
  newItem->setBackground( 2, QBrush( QColor( 127, 127, 127 ) ) );
  mReliefClassTreeWidget->addTopLevelItem( newItem );
}
开发者ID:stevenmizuno,项目名称:QGIS,代码行数:9,代码来源:qgsrasterterrainanalysisdialog.cpp

示例7: addContainer

QTreeWidgetItem* QgsAttributesTree::addContainer( QTreeWidgetItem* parent, QString title )
{
  QTreeWidgetItem *newItem = new QTreeWidgetItem( QList<QString>() << title );
  newItem->setBackground( 0 , QBrush( Qt::lightGray ) );
  newItem->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled );
  newItem->setData( 0 , Qt::UserRole , "container" );
  parent->addChild( newItem );
  newItem->setExpanded( true );
  return newItem;
}
开发者ID:bholland,项目名称:Quantum-GIS,代码行数:10,代码来源:qgsfieldsproperties.cpp

示例8: setActivePlayer

void PlayerListWidget::setActivePlayer(int playerId)
{
	QMapIterator<int, QTreeWidgetItem *> i(players);
	while (i.hasNext()) {
		i.next();
		QTreeWidgetItem *twi = i.value();
		QColor c = i.key() == playerId ? QColor(150, 255, 150) : Qt::white;
		twi->setBackground(4, c);
	}
}
开发者ID:Zors,项目名称:Cockatrice,代码行数:10,代码来源:playerlistwidget.cpp

示例9: addError

void KateBuildView::addError(const QString &filename, const QString &line,
                             const QString &column, const QString &message)
{
    bool isError=false;
    bool isWarning=false;
    QTreeWidgetItem* item = new QTreeWidgetItem(m_buildUi.errTreeWidget);
    item->setBackground(1, Qt::gray);
    // The strings are twice in case kate is translated but not make.
    if (message.contains(QStringLiteral("error")) ||
        message.contains(i18nc("The same word as 'make' uses to mark an error.","error")) ||
        message.contains(QStringLiteral("undefined reference")) ||
        message.contains(i18nc("The same word as 'ld' uses to mark an ...","undefined reference"))
       )
    {
        isError=true;
        item->setForeground(1, Qt::red);
        m_numErrors++;
        item->setHidden(false);
    }
    if (message.contains(QStringLiteral("warning")) ||
        message.contains(i18nc("The same word as 'make' uses to mark a warning.","warning"))
       )
    {
        isWarning=true;
        item->setForeground(1, Qt::yellow);
        m_numWarnings++;
        item->setHidden(m_buildUi.displayModeSlider->value() > 2);
    }
    item->setTextAlignment(1, Qt::AlignRight);

    // visible text
    //remove path from visible file name
    QFileInfo file(filename);
    item->setText(0, file.fileName());
    item->setText(1, line);
    item->setText(2, message.trimmed());

    // used to read from when activating an item
    item->setData(0, Qt::UserRole, filename);
    item->setData(1, Qt::UserRole, line);
    item->setData(2, Qt::UserRole, column);

    if ((isError==false) && (isWarning==false)) {
      item->setHidden(m_buildUi.displayModeSlider->value() > 1);
    }

    item->setData(0, IsErrorRole, isError);
    item->setData(0, IsWarningRole, isWarning);

    // add tooltips in all columns
    // The enclosing <qt>...</qt> enables word-wrap for long error messages
    item->setData(0, Qt::ToolTipRole, filename);
    item->setData(1, Qt::ToolTipRole, QStringLiteral("<qt>%1</qt>").arg(message));
    item->setData(2, Qt::ToolTipRole, QStringLiteral("<qt>%1</qt>").arg(message));
}
开发者ID:cmacq2,项目名称:kate,代码行数:55,代码来源:plugin_katebuild.cpp

示例10: search

void VarManager::search()
{
	setEnabled(false);

	QMultiMap<int, QString> vars = fieldArchive->searchAllVars();

	quint32 key;
	qint32 param;
	QTreeWidgetItem *item;
	QMap<int, bool> count;
	int lastVar=-1;

	QMapIterator<int, QString> i(vars);
	while(i.hasNext()) {
		i.next();
		if(lastVar == i.key())	continue;

		lastVar = i.key();
		JsmOpcode op(lastVar);
		key = op.key();
		param = op.param();
		count.insert(param, true);

		item = list->topLevelItem(param);
		item->setBackground(0, QColor(0xff,0xe5,0x99));

		if(key == 10 || key == 11 || key == 16) {
			item->setText(1, QString("%1Byte").arg(key == 16 ? "Signed " : ""));
		}
		else if(key == 12 || key == 13 || key == 17) {
			item->setText(1, QString("%1Word").arg(key == 17 ? "Signed " : ""));
			count.insert(param+1, true);
			list->topLevelItem(param+1)->setBackground(0, QColor(0xff,0xe5,0x99));
		}
		else if(key == 14 || key == 15 || key == 18) {
			item->setText(1, QString("%1Long").arg(key == 18 ? "Signed " : ""));
			count.insert(param+1, true);
			list->topLevelItem(param+1)->setBackground(0, QColor(0xff,0xe5,0x99));
			count.insert(param+2, true);
			list->topLevelItem(param+2)->setBackground(0, QColor(0xff,0xe5,0x99));
			count.insert(param+3, true);
			list->topLevelItem(param+3)->setBackground(0, QColor(0xff,0xe5,0x99));
		}
		QStringList fields(vars.values(lastVar));
		fields.append(item->text(3).split(", ", QString::SkipEmptyParts));
		fields.removeDuplicates();
		item->setText(3, fields.join(", "));
	}

	list->resizeColumnToContents(0);
	list->resizeColumnToContents(1);

	setEnabled(true);
	countLabel->setText(tr("Vars utilisés : %1/1536").arg(count.size()));
}
开发者ID:JeMaCheHi,项目名称:deling,代码行数:55,代码来源:VarManager.cpp

示例11: AddChildItem

/*!
    添加一个子节点。
    @para[in]  QTreeWidgetItem * parentItem  待添加节点的父节点
    @para[in]  const QString & name  节点名称
    @para[in]  const QString & value  节点值
    @return  QTreeWidgetItem*
*/
QTreeWidgetItem* QPatientInfoWidget::AddChildItem(QTreeWidgetItem* parentItem, const QString& name, const QString& value)
{
	QStringList itemStrList;
	itemStrList << name << value;
	QTreeWidgetItem* childItem = new QTreeWidgetItem(parentItem, itemStrList);

	if (NULL != m_bkgrdBrushPtr)
	{//背景色设置
		m_bkgrdBrushPtr->setColor(QColor(Qt::cyan));
		childItem->setBackground(0, *m_bkgrdBrushPtr);//name column
		if (value.isEmpty())
		{
			m_bkgrdBrushPtr->setColor(QColor(Qt::yellow));
		}
		childItem->setBackground(1, *m_bkgrdBrushPtr);//value column
	}

	parentItem->addChild(childItem);
	return childItem;
}
开发者ID:thisTerry,项目名称:ExportXmlViewer,代码行数:27,代码来源:qpatientinfowidget.cpp

示例12: populateColormapTreeWidget

void QgsSingleBandPseudoColorRendererWidget::populateColormapTreeWidget( const QList<QgsColorRampShader::ColorRampItem>& colorRampItems )
{
  mColormapTreeWidget->clear();
  QList<QgsColorRampShader::ColorRampItem>::const_iterator it = colorRampItems.constBegin();
  for ( ; it != colorRampItems.constEnd(); ++it )
  {
    QTreeWidgetItem* newItem = new QTreeWidgetItem( mColormapTreeWidget );
    newItem->setText( 0, QString::number( it->value, 'f' ) );
    newItem->setBackground( 1, QBrush( it->color ) );
    newItem->setText( 2, it->label );
  }
}
开发者ID:stevenmizuno,项目名称:QGIS,代码行数:12,代码来源:qgssinglebandpseudocolorrendererwidget.cpp

示例13: setFromRenderer

void QgsPalettedRendererWidget::setFromRenderer( const QgsRasterRenderer* r )
{
  const QgsPalettedRasterRenderer* pr = dynamic_cast<const QgsPalettedRasterRenderer*>( r );
  if ( pr )
  {
    //read values and colors and fill into tree widget
    int nColors = pr->nColors();
    QColor* colors = pr->colors();
    for ( int i = 0; i < nColors; ++i )
    {
      QTreeWidgetItem* item = new QTreeWidgetItem( mTreeWidget );
      item->setText( 0, QString::number( i ) );
      item->setBackground( 1, QBrush( colors[i] ) );
      item->setText( 2, pr->label( i ) );
    }
    delete[] colors;
  }
  else
  {
    //read default palette settings from layer
    QgsRasterDataProvider *provider = mRasterLayer->dataProvider();
    if ( provider )
    {
      QList<QgsColorRampShader::ColorRampItem> itemList = provider->colorTable( mBandComboBox->itemData( mBandComboBox->currentIndex() ).toInt() );
      QList<QgsColorRampShader::ColorRampItem>::const_iterator itemIt = itemList.constBegin();
      int index = 0;
      for ( ; itemIt != itemList.constEnd(); ++itemIt )
      {
        QTreeWidgetItem* item = new QTreeWidgetItem( mTreeWidget );
        item->setText( 0, QString::number( index ) );
        item->setBackground( 1, QBrush( itemIt->color ) );
        item->setText( 2, itemIt->label );
        ++index;
      }
    }
  }
}
开发者ID:NyakudyaA,项目名称:QGIS,代码行数:37,代码来源:qgspalettedrendererwidget.cpp

示例14: addAttribute

void QgsDiagramProperties::addAttribute( QTreeWidgetItem * item )
{
  QTreeWidgetItem *newItem = new QTreeWidgetItem( mDiagramAttributesTreeWidget );

  newItem->setText( 0, item->text( 0 ) );
  newItem->setData( 0, Qt::UserRole, item->data( 0, Qt::UserRole ) );
  newItem->setFlags( newItem->flags() & ~Qt::ItemIsDropEnabled );

  //set initial color for diagram category
  int red = 1 + ( int )( 255.0 * qrand() / ( RAND_MAX + 1.0 ) );
  int green = 1 + ( int )( 255.0 * qrand() / ( RAND_MAX + 1.0 ) );
  int blue = 1 + ( int )( 255.0 * qrand() / ( RAND_MAX + 1.0 ) );
  QColor randomColor( red, green, blue );
  newItem->setBackground( 1, QBrush( randomColor ) );
  mDiagramAttributesTreeWidget->addTopLevelItem( newItem );
}
开发者ID:Nikhil14,项目名称:QGIS,代码行数:16,代码来源:qgsdiagramproperties.cpp

示例15: on_mAutomaticColorButton_clicked

void QgsRasterTerrainAnalysisDialog::on_mAutomaticColorButton_clicked()
{
  QgsRelief relief( inputFile(), outputFile(), outputFormat() );
  QList< QgsRelief::ReliefColor > reliefColorList = relief.calculateOptimizedReliefClasses();
  QList< QgsRelief::ReliefColor >::iterator it = reliefColorList.begin();

  mReliefClassTreeWidget->clear();
  for ( ; it != reliefColorList.end(); ++it )
  {
    QTreeWidgetItem* item = new QTreeWidgetItem();
    item->setText( 0, QString::number( it->minElevation ) );
    item->setText( 1, QString::number( it->maxElevation ) );
    item->setBackground( 2, QBrush( it->color ) );
    mReliefClassTreeWidget->addTopLevelItem( item );
  }
}
开发者ID:stevenmizuno,项目名称:QGIS,代码行数:16,代码来源:qgsrasterterrainanalysisdialog.cpp


注:本文中的QTreeWidgetItem::setBackground方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。