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


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

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


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

示例1: updatePlugins

void SetupPluginsDialog::updatePlugins()
{
	FItemElement.clear();
	ui.twtPlugins->clearContents();
	ui.twtPlugins->setRowCount(0);

	QDomElement pluginElem = FPluginsSetup.documentElement().firstChildElement();
	while (!pluginElem.isNull())
	{
		QString name = pluginElem.firstChildElement("name").text().isEmpty() ? pluginElem.tagName() : pluginElem.firstChildElement("name").text();
		QTableWidgetItem *nameItem = new QTableWidgetItem(name);
		if (pluginElem.attribute("enabled","true")=="true")
		{
			if (FPluginManager->pluginInstance(pluginElem.attribute("uuid"))==NULL)
				nameItem->setForeground(Qt::red);
			nameItem->setCheckState(Qt::Checked);
		}
		else
		{
			nameItem->setForeground(Qt::gray);
			nameItem->setCheckState(Qt::Unchecked);
		}
		nameItem->setCheckState(pluginElem.attribute("enabled","true")=="true" ? Qt::Checked : Qt::Unchecked);

		QTableWidgetItem *fileItem = new QTableWidgetItem(pluginElem.tagName());

		ui.twtPlugins->setRowCount(ui.twtPlugins->rowCount()+1);
		ui.twtPlugins->setItem(ui.twtPlugins->rowCount()-1, COL_NAME, nameItem);
		ui.twtPlugins->setItem(nameItem->row(), COL_FILE, fileItem);

		FItemElement.insert(nameItem,pluginElem);
		pluginElem = pluginElem.nextSiblingElement();
	}
	ui.twtPlugins->sortItems(COL_NAME,Qt::AscendingOrder);
}
开发者ID:RandomWalkEagle,项目名称:Contacts,代码行数:35,代码来源:setuppluginsdialog.cpp

示例2: busMonitorAddItem

void MainWindow::busMonitorAddItem( bool isRequest,
					uint8_t slave,
					uint8_t func,
					uint16_t addr,
					uint16_t nb,
					uint16_t expectedCRC,
					uint16_t actualCRC )
{
	QTableWidget * bm = ui->busMonTable;
	const int rowCount = bm->rowCount();
	bm->setRowCount( rowCount+1 );

	QTableWidgetItem * ioItem = new QTableWidgetItem( isRequest ? tr( "Req >>" ) : tr( "<< Resp" ) );
	QTableWidgetItem * slaveItem = new QTableWidgetItem( QString::number( slave ) );
	QTableWidgetItem * funcItem = new QTableWidgetItem( QString::number( func ) );
	QTableWidgetItem * addrItem = new QTableWidgetItem( QString::number( addr ) );
	QTableWidgetItem * numItem = new QTableWidgetItem( QString::number( nb ) );
	QTableWidgetItem * crcItem = new QTableWidgetItem;
	if( func > 127 )
	{
		addrItem->setText( QString() );
		numItem->setText( QString() );
		funcItem->setText( tr( "Exception (%1)" ).arg( func-128 ) );
		funcItem->setForeground( Qt::red );
	}
	else
	{
		if( expectedCRC == actualCRC )
		{
			crcItem->setText( QString().sprintf( "%.4x", actualCRC ) );
		}
		else
		{
			crcItem->setText( QString().sprintf( "%.4x (%.4x)", actualCRC, expectedCRC ) );
			crcItem->setForeground( Qt::red );
		}
	}
	ioItem->setFlags( ioItem->flags() & ~Qt::ItemIsEditable );
	slaveItem->setFlags( slaveItem->flags() & ~Qt::ItemIsEditable );
	funcItem->setFlags( funcItem->flags() & ~Qt::ItemIsEditable );
	addrItem->setFlags( addrItem->flags() & ~Qt::ItemIsEditable );
	numItem->setFlags( numItem->flags() & ~Qt::ItemIsEditable );
	crcItem->setFlags( crcItem->flags() & ~Qt::ItemIsEditable );
	bm->setItem( rowCount, 0, ioItem );
	bm->setItem( rowCount, 1, slaveItem );
	bm->setItem( rowCount, 2, funcItem );
	bm->setItem( rowCount, 3, addrItem );
	bm->setItem( rowCount, 4, numItem );
	bm->setItem( rowCount, 5, crcItem );
	bm->verticalScrollBar()->setValue( 100000 );
}
开发者ID:GaussCheng,项目名称:honeywell_monitor,代码行数:51,代码来源:mainwindow.cpp

示例3: SetWeekDays

 //Method to set week days
 void MonthView::SetWeekDays()
         {

                 //Headers
                 int weekDay = 1;

                 for(int i = 0 ;i < 7;i++)
                 {
                         //Set column width
                         ui->tblHeader->setColumnWidth(i,60);
                         ui->tblDates->setColumnWidth(i,60);

                         QTableWidgetItem *item = new QTableWidgetItem();

                         QString name = QDate::shortDayName(weekDay++);
                         item->setText(name);
                          item->setTextAlignment(Qt::AlignTop | Qt::AlignHCenter);
                          if( i >4)
                          {
                                item->setBackgroundColor(QColor::fromRgb(201,72,135));
                                item->setForeground(QBrush(QColor::fromRgb(136,36,89)));
                          }

                         ui->tblHeader->setItem(0,i,item);
                 }

                 //Add the column for weekly totals
                 ui->tblHeader->setColumnWidth(7,120);
                 ui->tblDates->setColumnWidth(7,120);
                 QTableWidgetItem *item = new QTableWidgetItem();
                  item->setText("Weekly Totals");
                  item->setTextAlignment(Qt::AlignTop | Qt::AlignHCenter);
                 ui->tblHeader->setItem(0,7,item);

         }
开发者ID:NeerajDev,项目名称:GrizzlyPeak,代码行数:36,代码来源:MonthView.cpp

示例4: setColorMap

void ColorMapEditor::setColorMap(const QwtLinearColorMap& map)
{
scaleColorsBox->setChecked(map.mode() == QwtLinearColorMap::ScaledColors);

QwtArray <double> colors = map.colorStops();
int rows = (int)colors.size();
table->setRowCount(rows);
table->blockSignals(true);
	
for (int i = 0; i < rows; i++)
	{
	QwtDoubleInterval range = QwtDoubleInterval(min_val, max_val);
	double val = min_val + colors[i] * range.width();
		
	QTableWidgetItem *it = new QTableWidgetItem(QString::number(val));
    table->setItem(i, 0, it);
		
	QColor c = QColor(map.rgb(QwtDoubleInterval(0, 1), colors[i]));
	it = new QTableWidgetItem(c.name());
	it->setFlags(Qt::ItemFlags(!Qt::ItemIsEditable));
	it->setBackground(QBrush(c));
	it->setForeground(QBrush(c));
    table->setItem(i, 1, it);
	}
table->blockSignals(false);
	
color_map = map;
}
开发者ID:highperformancecoder,项目名称:scidavis,代码行数:28,代码来源:ColorMapEditor.cpp

示例5: setForeground

 int TableWidgetItem::setForeground ( lua_State * L )// ( const QBrush & brush )void
 {
	 QTableWidgetItem* lhs = ValueInstaller2<QTableWidgetItem>::check( L, 1 );
	 QBrush* brush = ValueInstaller2<QBrush>::check( L, 2 );
	 lhs->setForeground( *brush );
	 return 0;
 }
开发者ID:Wushaowei001,项目名称:NAF,代码行数:7,代码来源:QtlTableWidgetItem.cpp

示例6: insertLevel

void ColorMapEditor::insertLevel()
{
int row = table->currentRow();
QwtDoubleInterval range = QwtDoubleInterval(min_val, max_val);

double val = 0.5*(table->item(row, 0)->text().toDouble() + table->item(row - 1, 0)->text().toDouble());
double mapped_val = (val - min_val)/range.width();
QColor c = QColor(color_map.rgb(QwtDoubleInterval(0, 1), mapped_val));

table->blockSignals(true);
table->insertRow(row);

QTableWidgetItem *it = new QTableWidgetItem(QString::number(val));
table->setItem(row, 0, it);
		
it = new QTableWidgetItem(c.name());
it->setFlags(Qt::ItemFlags(!Qt::ItemIsEditable));
it->setBackground(QBrush(c));
it->setForeground(QBrush(c));
table->setItem(row, 1, it);
table->blockSignals(false);
	
enableButtons(table->currentRow(), 0);
updateColorMap();
}
开发者ID:highperformancecoder,项目名称:scidavis,代码行数:25,代码来源:ColorMapEditor.cpp

示例7: updateWithBaseInflation

void WidgetTableProgression::updateWithBaseInflation(int base, double inflation,
    int maxLevel, QHash<int, int> *subTable)
{
    int t = 0, exp;
    double pow = 2.4 + inflation / 100.0;
    QTableWidgetItem *item;

    if (m_totalWidget != nullptr) {
        m_totalWidget->setItem(0, 0, new QTableWidgetItem(QString::number(1)));
        m_totalWidget->setItem(0, 1, new QTableWidgetItem(QString::number(0)));
    }
    for (int i = 2; i <= maxLevel; i++) {
        exp = qFloor(base * (qPow(i + 3, pow) / qPow(5, pow)));
        if (m_totalWidget != nullptr) {
            t += exp;
            m_totalWidget->setItem(i - 1, 0, new QTableWidgetItem(QString::number(i)));
            m_totalWidget->setItem(i - 1, 1, new QTableWidgetItem(QString::number(t)));
        }
        setItem(i - 2, 0, new QTableWidgetItem(QString::number(i - 1)));
        setItem(i - 2, 1, new QTableWidgetItem(QString::number(exp)));
    }

    // Complete with exp table
    if (m_totalWidget != nullptr) {
        QHash<int, int>::const_iterator i;
        if (subTable != nullptr) {
            for (i = subTable->begin(); i != subTable->end(); i++) {
                this->item(i.key() - 1, 0)->setText(QString::number(i.value()));
                item = this->item(i.key() - 1, 1);
                item->setText(QString::number(i.value()));
                item->setForeground(SUB_EDITED_COLOR);
            }
        }
        for (i = m_table->begin(); i != m_table->end(); i++) {
            this->item(i.key() - 1, 0)->setText(QString::number(i.value()));
            item = this->item(i.key() - 1, 1);
            item->setText(QString::number(i.value()));
            item->setForeground(m_editedColor);
        }
        if (!m_table->isEmpty() || (subTable != nullptr && !subTable->isEmpty()))
        {
            updateTotal();
        }
    }
    m_completing = false;
}
开发者ID:Wano-k,项目名称:RPG-Paper-Maker,代码行数:46,代码来源:widgettableprogression.cpp

示例8: addItem

void MyIconView::addItem(int &col, int &row, dirEntryT *e){
    QTableWidgetItem *item;
    item = new QTableWidgetItem(QString::fromStdString(e->name));
    item->setIcon(base_icon);
    if(e->type == e->Type::DIR){
        item->setIcon(dir_icon);
        item->setFont(bold_font);
    }else if(e->type == e->Type::LINK){
        item->setFont(italic_font);
        item->setForeground(QBrush(QColor(255, 0, 0)));
    }else if(e->type == e->Type::ARCHIVE){
        item->setIcon(ar_icon);
        item->setFont(bold_font);
        item->setForeground(QBrush(QColor(255, 0, 255)));
    }else item->setFont(base_font);
    setItem(row, col, item);

}
开发者ID:vojtsek,项目名称:DirectoryViewer,代码行数:18,代码来源:myiconview.cpp

示例9: showSkippedMessage

void MessageHandler::showSkippedMessage(int skipped_count)
{
    if (skipped_count > 0) {
        QTableWidgetItem * item = new QTableWidgetItem(tr("%1 files skipped").arg(skipped_count));
        item->setBackground(QBrush(Qt::darkGray));
        item->setForeground(QBrush(Qt::white));
        item->setIcon(QIcon(":/new/prefix1/images/file.png"));
        insertSpannedItem(item);
    }
}
开发者ID:matus-tomlein,项目名称:synkron,代码行数:10,代码来源:messagehandler.cpp

示例10: populateTable

//------------------------------------------------------------
void UDbScriptAccess::populateTable(int row, int col, QString text, QString textColor)
{
	QTableWidgetItem *item = new QTableWidgetItem("");
	item->setData(2, text);
	item->setForeground(QBrush(QColor(textColor)));
	item->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
	__tableWidgetEdited->blockSignals(true);
	__tableWidgetEdited->setItem(row, col, item);
	__tableWidgetEdited->blockSignals(false);
}
开发者ID:utech,项目名称:tke,代码行数:11,代码来源:UDbScriptAccess.cpp

示例11: showFitPage

void FitDialog::showFitPage()
{
    int param_table_rows = boxParams->rowCount();

	QString par = boxParam->text().simplified();
	QStringList paramList = par.split(QRegExp("[,;]+[\\s]*"), QString::SkipEmptyParts);
	int parameters = paramList.count();
	boxParams->setRowCount(parameters);
    boxParams->hideColumn(2);

	if (parameters > 7)
		parameters = 7;
	boxParams->setMinimumHeight(4+(parameters+1)*boxParams->horizontalHeader()->height());

    for (int i = param_table_rows; i<paramList.count(); i++)
	{
        QTableWidgetItem *it = new QTableWidgetItem(paramList[i]);
        it->setFlags(!Qt::ItemIsEditable);
        it->setBackground(QBrush(Qt::lightGray));
        it->setForeground(QBrush(Qt::darkRed));
        QFont font = it->font();
        font.setBold(true);
        it->setFont(font);
        boxParams->setItem(i, 0, it);

        it = new QTableWidgetItem(QLocale().toString(1.0, 'f', boxPrecision->value()));
        it->setTextAlignment(Qt::AlignRight);
        boxParams->setItem(i, 1, it);
	}
    for (int i = 0; i<paramList.count(); i++)
        boxParams->item (i, 0)->setText(paramList[i]);

	// FIXME: this check is pretty ugly, should be changed to a more elegant way some time
	if (!boxUseBuiltIn->isChecked() ||
		(boxUseBuiltIn->isChecked()&& categoryBox->currentRow()!=3 && categoryBox->currentRow()!=1))
	{
        boxParams->showColumn(2);

		for (int i = 0; i<boxParams->rowCount(); i++ )
		{
            QTableWidgetItem *it = new QTableWidgetItem();
            it->setFlags(!Qt::ItemIsEditable);
            it->setBackground(QBrush(Qt::lightGray));
            boxParams->setItem(i, 2, it);

			QCheckBox *cb = new QCheckBox();
            boxParams->setCellWidget(i, 2, cb);
		}
	}

	boxFunction->setText(editBox->text().simplified());
	lblFunction->setText(boxName->text() +" (x, " + par + ")");

	tw->setCurrentWidget (fitPage);
}
开发者ID:rgonzga,项目名称:scidavis,代码行数:55,代码来源:FitDialog.cpp

示例12: createItem

QTableWidgetItem* IDEWidget::createItem(const QString& text, bool link)
{
	QTableWidgetItem* item = new QTableWidgetItem(text);
	item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);

	if (link) {
		item->setForeground(linkBrush);
		item->setToolTip(tr("Double click to open file"));
	}

	return item;
}
开发者ID:alemariusnexus,项目名称:gtatools,代码行数:12,代码来源:IDEWidget.cpp

示例13: addStatusToTable

void ProcessingManager::addStatusToTable(int processId, ProjectImage* image, const QString& text, bool error) {
    QStringList cell = text.split(';');
    for(QString s : cell) {
        if(!s.trimmed().isEmpty()) {
            QTableWidgetItem* idItem = new QTableWidgetItem();
            idItem->setFlags(idItem->flags() ^ Qt::ItemIsEditable);
            idItem->setText(QString::number(processId));
            
            QTableWidgetItem* imageItem = new QTableWidgetItem();
            imageItem->setFlags(imageItem->flags() ^ Qt::ItemIsEditable);
            QString imageStr, imageToolTip;
            if(image) {
                imageStr = image->toString();
                imageToolTip = image->workingPath();
            }
            imageItem->setText(imageStr);
            imageItem->setToolTip(imageToolTip);
            
            QTableWidgetItem* processItem = new QTableWidgetItem();
            processItem->setFlags(processItem->flags() ^ Qt::ItemIsEditable);
            processItem->setText(QTime::currentTime().toString("hh:mm:ss.zzz") + " "  + text);
            
            if(error) {
                idItem->setForeground(Qt::red);
                imageItem->setForeground(Qt::red);
                processItem->setForeground(Qt::red);
            }
            int row = statusEntryTable_->rowCount();
            statusEntryTable_->setSortingEnabled(false);
            statusEntryTable_->insertRow(row);
            statusEntryTable_->setItem(row, 0, idItem);
            statusEntryTable_->setItem(row, 1, imageItem);
            statusEntryTable_->setItem(row, 2, processItem);
            statusEntryTable_->setSortingEnabled(true);
        }
    }
    statusEntryTable_->resizeColumnToContents(0);
    statusEntryTable_->resizeColumnToContents(1);
    statusEntryTable_->scrollToBottom();
}
开发者ID:C-CINA,项目名称:2dx,代码行数:40,代码来源:ProcessingManager.cpp

示例14: on_pushButton_clicked

void MainWindow::on_pushButton_clicked()
{

    for(int i=0;i<9;i++)
    {
        for(int j=0;j<9;j++)
        {
            QString str;
            QTableWidgetItem* itm = ui->tableWidget->item( i, j );
            if (itm)
            {
                str = itm->text();
                input[i][j]=str.toInt();
                output[i][j]=input[i][j];
            }
            else output[i][j]=input[i][j]=0;
        }
    }
    if(solve(0,0))
    {        ui->label->setText("YES");

    for(int i=0;i<9;i++)
    {
        for(int j=0;j<9;j++)
        {
            QTableWidgetItem *itab;
                   itab = new QTableWidgetItem; // add this line
                   QString s = QString::number(output[i][j]);
                   itab->setText(s);
                   if(input[i][j]!=0)
                   {
                       itab->setForeground(QColor::fromRgb(255,0,0)); //make this item red.
                   }
                   ui->tableWidget->setItem(i, j, itab);
        }
    }
    }
    else ui->label->setText("NO");
    /*
     QTableWidgetItem *itab;
            itab = new QTableWidgetItem; // add this line
            QString s = QString::number(j);
            itab->setText(s);
            ui->tableWidget->setItem(i, j, itab);
     */


    //delete(itab);
}
开发者ID:tanmaydatta,项目名称:sudoku-solver-QT,代码行数:49,代码来源:mainwindow.cpp

示例15: on_cellChanged

void WidgetTableProgression::on_cellChanged(int row, int column) {
    if (!m_completing && m_table != nullptr) {
        if (column == 0) {
            item(row, column)->setText(QString::number(row + 1));
        } else {
            QString value = item(row, column)->text();
            int correctedValue = value.toInt();
            QTableWidgetItem *itemProgression = item(row, 1);
            itemProgression->setText(QString::number(correctedValue));
            itemProgression->setForeground(m_editedColor);
            m_table->insert(row + 1, correctedValue);
            updateTotal();
        }
    }
}
开发者ID:Wano-k,项目名称:RPG-Paper-Maker,代码行数:15,代码来源:widgettableprogression.cpp


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