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


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

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


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

示例1: PopulateTreeWidgetItems

void FlyLinks::PopulateTreeWidgetItems(
        const QMap<QString,QString>& objDataMap) {

    QMapIterator<QString,QString> objIterMap(objDataMap);
    QFont font;
    font.setPointSizeF(8.25);
    font.setUnderline(true);
    m_pObjPopup->setSortingEnabled(false);

    QBrush brush(QColor(85, 0, 255, 255));
    brush.setStyle(Qt::NoBrush);

    QTreeWidgetItem *pItem = new QTreeWidgetItem(m_pObjPopup);
    pItem = m_pObjPopup->headerItem();
    pItem->setText(0,tr("1"));
    pItem->setFont(0, font);
    pItem->setForeground(0, brush);
    pItem->setTextAlignment(0, Qt::AlignLeft);
    m_pObjTreeItemsVec.push_back(pItem);

    int iCount = 0;
    while(objIterMap.hasNext()) {
        objIterMap.next();
        QBrush brush(QColor(85, 0, 255, 255));
        brush.setStyle(Qt::NoBrush);
        QTreeWidgetItem *pItem = new QTreeWidgetItem(m_pObjPopup);
        pItem = m_pObjPopup->topLevelItem(iCount++);
        pItem->setText(0,objIterMap.key());
        pItem->setData(0,Qt::UserRole,objIterMap.value());
        pItem->setFont(0, font);
        pItem->setForeground(0, brush);
        pItem->setTextAlignment(0, Qt::AlignLeft);
    }
}
开发者ID:PSaraph,项目名称:FlyLabel,代码行数:34,代码来源:FlyLinks.cpp

示例2: QTreeWidgetItem

void K3b::ImageWritingDialog::Private::createCueBinItems( const QString& cueFile, const QString& imageFile )
{
    QTreeWidgetItem* isoRootItem = new QTreeWidgetItem( infoView );
    isoRootItem->setText( 0, i18n("Detected:") );
    isoRootItem->setText( 1, i18n("Cue/bin image") );
    isoRootItem->setForeground( 0, infoTextColor );
    isoRootItem->setIcon( 1, KIcon( "application-x-cd-image") );
    isoRootItem->setTextAlignment( 0, Qt::AlignRight );

    QTreeWidgetItem* item = new QTreeWidgetItem( infoView );
    item->setText( 0, i18n("Filesize:") );
    item->setText( 1, KIO::convertSize( K3b::filesize(KUrl(imageFile)) ) );
    item->setForeground( 0, infoTextColor );
    item->setTextAlignment( 0, Qt::AlignRight );

    item = new QTreeWidgetItem( infoView );
    item->setText( 0, i18n("Image file:") );
    item->setText( 1, imageFile );
    item->setForeground( 0, infoTextColor );
    item->setTextAlignment( 0, Qt::AlignRight );

    item = new QTreeWidgetItem( infoView );
    item->setText( 0, i18n("Cue file:") );
    item->setText( 1, cueFile );
    item->setForeground( 0, infoTextColor );
    item->setTextAlignment( 0, Qt::AlignRight );
}
开发者ID:franhaufer,项目名称:k3b,代码行数:27,代码来源:k3bimagewritingdialog.cpp

示例3: 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

示例4: addGroup

void TreeArea::addGroup(){
    // Classic method to show a new window with a TextBox
    bool ok;
    QString text = QInputDialog::getText(this, "Add group...", "Name:", QLineEdit::Normal, QString::null, &ok).trimmed();
    // If the user entered a text
    if(ok && !text.isEmpty()){
        // Check that there isnt another group with the same name
        int i = 0;
        if (!this->groupsTree->findItems(text, Qt::MatchExactly,0).isEmpty()){
            for (QTreeWidgetItem* &a : this->groupsTree->findItems(text, Qt::MatchExactly,0)){
                if (a->parent() == NULL) {
                    i++;
                }
            }
        }

        if (i == 0){
            // Create a new item named after the text entered
            QTreeWidgetItem* a = new QTreeWidgetItem(this->groupsTree);
            a->setText(0, text);
            // Insert the item at the end of the attribute: groups
            this->groups.push_back(a);
            int size = this->groupsPalette->size();
            this->groupsPalette->insert(a, this->palette->at(size%8));
            a->setForeground(0, QBrush(palette->at(size%8)));
        }
        else {
            QMessageBox::warning(this, "Error", "Name already chosen.");
    }
    }

}
开发者ID:AurelienHP,项目名称:pgrou,代码行数:32,代码来源:TreeArea.cpp

示例5: 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

示例6: 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();
  }
开发者ID:jlaura,项目名称:isis3,代码行数:51,代码来源:HistoryTreeWidget.cpp

示例7: refreshNotebook

void NotebookList::refreshNotebook()
{
	QByteArray result = svnController->doUpdate();
	QStringList fileList;

	char fileName[64]; int fileP=0;
	enum STATES {NOTHING, START, SKIP, PROCESSING};
	STATES state = NOTHING;

	for(int i=0;i<result.length();i++)
	{
		switch(state)
		{
		case NOTHING:
			if(i > 1 && result.at(i-1) == '\n' && result.at(i) == 'A') state=START;
			if(i==0 && result.at(i) == 'A') state=START;
			break;

		case START:
			if(result.at(i) == ' ') state=SKIP;
			else state=NOTHING;
			break;

		case SKIP:
			if(result.at(i) == ' ') state=SKIP;
			else
			{
				state=PROCESSING;
				fileP=0;
				fileName[fileP++]=result.at(i);
			}
			break;

		case PROCESSING:
			if(result.at(i) != '\n') fileName[fileP++]=result.at(i);
			else
			{
				fileName[fileP]=0;
				QString t(fileName);
				fileList << t;
				state=NOTHING;
			}
			break;
		}
	}

	QTreeWidgetItem *t;
	for(int i=0;i<fileList.size();i++)
	{
		t = createChildItem(fileList.at(i));
		t->setText(0, fileList.at(i));
		t->setText(0, "dont know");
		t->setForeground(0, QBrush(QColor(Qt::blue)));
		t->setIcon(0,bookmarkIcon); // newIcon 으로 대체하기
	}
}
开发者ID:alien81,项目名称:opennote,代码行数:56,代码来源:NotebookExplorer.cpp

示例8: update

void StateManagerWindow::update() {
  //iterate all list items
  QList<QTreeWidgetItem*> items = list->findItems("", Qt::MatchContains);
  for(unsigned i = 0; i < items.count(); i++) {
    QTreeWidgetItem *item = items[i];
    unsigned n = item->data(0, Qt::UserRole).toUInt();
    if(isStateValid(n) == false) {
      item->setForeground(0, QBrush(QColor(128, 128, 128)));
      item->setForeground(1, QBrush(QColor(128, 128, 128)));
      item->setText(1, "Empty");
    } else {
      item->setForeground(0, QBrush(QColor(0, 0, 0)));
      item->setForeground(1, QBrush(QColor(0, 0, 0)));
      item->setText(1, getStateDescription(n));
    }
  }

  for(unsigned n = 0; n <= 1; n++) list->resizeColumnToContents(n);
}
开发者ID:Arnethegreat,项目名称:bsnes-plus,代码行数:19,代码来源:statemanager.cpp

示例9: addUrl

void UrlDialog::addUrl(QString url, QString window, QString count, QString timestamp)
{
    QTreeWidgetItem * UrlItem = new QTreeWidgetItem(m_pUrlList);

    UrlItem->setText(0, url);
    UrlItem->setText(1, window);
    UrlItem->setText(2, count);
    UrlItem->setText(3, timestamp);

    UrlItem->setForeground(0, KVI_OPTION_MIRCCOLOR(KVI_OPTION_MSGTYPE(KVI_OUT_URL).fore()));
    UrlItem->setForeground(1, KVI_OPTION_MIRCCOLOR(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore()));
    UrlItem->setForeground(2, KVI_OPTION_MIRCCOLOR(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore()));
    UrlItem->setForeground(3, KVI_OPTION_MIRCCOLOR(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore()));

    m_pUrlList->resizeColumnToContents(0);
    m_pUrlList->resizeColumnToContents(3);
    m_pUrlList->resizeColumnToContents(2);
    m_pUrlList->resizeColumnToContents(1);
}
开发者ID:un1versal,项目名称:KVIrc,代码行数:19,代码来源:libkviurl.cpp

示例10: addDivider

void DlgTagFetcher::addDivider(const QString& text, QTreeWidget* parent) const {
    QTreeWidgetItem* item = new QTreeWidgetItem(parent);
    item->setFirstColumnSpanned(true);
    item->setText(0, text);
    item->setFlags(Qt::NoItemFlags);
    item->setForeground(0, palette().color(QPalette::Disabled, QPalette::Text));

    QFont bold_font(font());
    bold_font.setBold(true);
    item->setFont(0, bold_font);
}
开发者ID:dot-Sean,项目名称:mixxx,代码行数:11,代码来源:dlgtagfetcher.cpp

示例11: generateDataItem

QTreeWidgetItem* PListEditorWidget::generateDataItem(PList::Node* node )
{
	PList::Data* data = (PList::Data*) node;
	
	QTreeWidgetItem* item = new QTreeWidgetItem();
	
	item->setText (NameColumn, "<unknown>");
	item->setText (TypeColumn, "Data");
	item->setText (ValueColumn, "( " + QString::number(data->GetValue().size()) + " bytes)");
	item->setForeground(ValueColumn, Qt::gray);
	
	return item;
}
开发者ID:thothonegan,项目名称:KPlistEditor,代码行数:13,代码来源:plisteditorwidget.cpp

示例12: updateQos

void BatchQosConfDialog::updateQos()
{
    for( int i=0; i < ui->treeWidgetCons->topLevelItemCount(); ++i ){
        QTreeWidgetItem *item = ui->treeWidgetCons->topLevelItem(i);
        yarp::os::QosStyle fromStyle, toStyle;
        if(yarp::os::NetworkBase::getConnectionQos(item->text(1).toUtf8().constData(),
                                                   item->text(2).toUtf8().constData(), fromStyle, toStyle)) {
            QString qosStr = NetworkProfiler::packetPrioToString(fromStyle.getPacketPriorityAsLevel()).c_str();
            QBrush b;
            switch(fromStyle.getPacketPriorityAsLevel()) {
                case yarp::os::QosStyle::PacketPriorityNormal : {
                    b.setColor(Qt::black);
                    break;
                }
                case yarp::os::QosStyle::PacketPriorityLow : {
                    b.setColor(QColor(255,215,0));
                    break;
                }
                case yarp::os::QosStyle::PacketPriorityHigh : {
                    b.setColor(QColor(255,140,0));
                    break;
                }
                case yarp::os::QosStyle::PacketPriorityCritical : {
                    b.setColor(Qt::red);
                    break;
                }
                case yarp::os::QosStyle::PacketPriorityInvalid : {
                    b.setColor(Qt::black);
                    break;
                }
                default: {
                    b.setColor(Qt::black);
                }
            }
            item->setForeground( 0 , b);
            item->setText(0, qosStr);
            qosStr += ", " + QString::number(fromStyle.getThreadPolicy()) + ", " + QString::number(fromStyle.getThreadPriority());
            item->setText(4, qosStr);
            qosStr.clear();
            qosStr = NetworkProfiler::packetPrioToString(toStyle.getPacketPriorityAsLevel()).c_str();
            qosStr += ", " + QString::number(toStyle.getThreadPolicy()) + ", " + QString::number(toStyle.getThreadPriority());
            item->setText(5, qosStr);
        }
        else
            yWarning()<<"Cannot retrive Qos property of"<<item->text(0).toUtf8().constData()<<"->"<<item->text(0).toUtf8().constData();
    }
    ui->treeWidgetCons->update();
}
开发者ID:robotology,项目名称:yarpviz,代码行数:48,代码来源:batchqosconfdialog.cpp

示例13: QDialog

DeviceFilterGUIDialog::DeviceFilterGUIDialog(DeviceFilterGUI* gui, DeviceFilterGUIFactory* factory, const QString& pattern)
	: QDialog(gui),
	ui(new Ui::DeviceFilterGUIDialog)
{
	ui->setupUi(this);

	bool all = pattern.trimmed() == "all";
	ui->allDevicesCheckBox->setChecked(all);

	QStringList labels;
	labels.append(tr("Connection"));
	labels.append(tr("Device"));
	labels.append(tr("State"));
	ui->treeWidget->setHeaderLabels(labels);
	QTreeWidgetItem* outputNode = new QTreeWidgetItem(ui->treeWidget, QStringList(tr("Playback devices")));
	outputNode->setExpanded(true);
	QTreeWidgetItem* inputNode = new QTreeWidgetItem(ui->treeWidget, QStringList(tr("Capture devices")));
	inputNode->setExpanded(true);
	const QList<DeviceAPOInfo>& devices = factory->getDevices();
	for (const DeviceAPOInfo& apoInfo : devices)
	{
		QStringList values;
		values.append(QString::fromStdWString(apoInfo.connectionName));
		values.append(QString::fromStdWString(apoInfo.deviceName));
		QString state;
		if (apoInfo.isInstalled)
			state = tr("APO installed");
		else
			state = tr("APO not installed");
		values.append(state);
		QTreeWidgetItem* item = new QTreeWidgetItem(apoInfo.isInput ? inputNode : outputNode, values);

		wstring deviceString = apoInfo.connectionName + L" " + apoInfo.deviceName + L" " + apoInfo.deviceGuid;
		bool matches = !all && DeviceFilterFactory::matchDevice(deviceString, pattern.toStdWString());
		item->setCheckState(0, matches ? Qt::Checked : Qt::Unchecked);
		item->setData(0, Qt::UserRole, QVariant::fromValue(&apoInfo));
		item->setHidden(!matches && !apoInfo.isInstalled && ui->showOnlyInstalledCheckBox->isChecked());
		if (!apoInfo.isInstalled)
			for (int i = 0; i < ui->treeWidget->columnCount(); i++)
				item->setForeground(i, QBrush(Qt::gray));
	}

	for (int i = 0; i < ui->treeWidget->columnCount(); i++)
		ui->treeWidget->resizeColumnToContents(i);
}
开发者ID:Noiled,项目名称:equalizerapo,代码行数:45,代码来源:DeviceFilterGUIDialog.cpp

示例14: changeSortColor

void TreeArea::changeSortColor(int clickedTree){

    QTreeWidgetItem* item;

    if (clickedTree == TreeArea::clickInSortsTree){
        item = this->sortsTree->currentItem();
    }

    if (clickedTree == TreeArea::clickInGroupsTree){
        item = this->groupsTree->currentItem();
    }

    // Get its name
    QString text = item->text(0);
    // Find the sort in the myArea that has the same name
    GSortPtr sortFound = this->myPHPtr->getGraphicsScene()->getGSort(text.toStdString());

    // Open the Color Dialog
    QColor couleur = QColorDialog::getColor();

    if (!couleur.isValid()) {
        return ;
    } else {
            // Set the color of the sort's rect item with the chosen color
            sortFound->getRect()->setBrush(QBrush(QColor(couleur)));
    }

    // Set the color of the item in the sortsTree to the same color
    item->setForeground(0, QBrush(QColor(couleur)));

    if (clickedTree == TreeArea::clickInSortsTree){
        // Set the same color 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){
            a->setForeground(0, QBrush(QColor(couleur)));
        }
    }
    if (clickedTree == TreeArea::clickInGroupsTree){
        // Set the same color 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){
            a->setForeground(0, QBrush(QColor(couleur)));
        }
    }
}
开发者ID:AurelienHP,项目名称:pgrou,代码行数:45,代码来源:TreeArea.cpp

示例15: updateGroupHeadings

void KateStyleTreeWidget::updateGroupHeadings()
{
  for(int i = 0; i < topLevelItemCount(); i++) {
    QTreeWidgetItem* currentTopLevelItem = topLevelItem(i);
    QTreeWidgetItem* firstChild = currentTopLevelItem->child(0);
    
    if(firstChild) {
      QColor foregroundColor = firstChild->data(KateStyleTreeWidgetItem::Foreground, Qt::DisplayRole).value<QColor>();
      QColor backgroundColor = firstChild->data(KateStyleTreeWidgetItem::Background, Qt::DisplayRole).value<QColor>();
      
      currentTopLevelItem->setForeground(KateStyleTreeWidgetItem::Context, foregroundColor);
      
      if(backgroundColor.isValid()) {
        currentTopLevelItem->setBackground(KateStyleTreeWidgetItem::Context, backgroundColor);
      }
    }
  }
}
开发者ID:fluxer,项目名称:kde-baseapps,代码行数:18,代码来源:katestyletreewidget.cpp


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