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


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

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


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

示例1: setCenter

void KernelTable::setCenter(int row, int column)
{
	if (row <= 0)
		row = 1;
	if (row > getRows())
		row = getRows();
	if (column <= 0)
		column = 1;
	if (column > getColumns())
		column = getColumns();

	centerRowBox->setValue(row);
	centerColumnBox->setValue(column);

	QTableWidgetItem *item;
	for (int i = 0; i < getRows(); ++i)
		for (int j = 0; j < getColumns(); ++j) {
			item = tableWidget->item(i, j);
			if (item == 0) {
				item = new QTableWidgetItem("0.0");
				tableWidget->setItem(i, j, item);
			}
			if (i + 1 == row && j + 1 == column)
				item->setBackground(QBrush(Qt::gray));
			else
				item->setBackground(QBrush(Qt::white));
		}
}
开发者ID:maximesong,项目名称:voici,代码行数:28,代码来源:KernelTable.cpp

示例2: updateTable

void AssociationsDialog::updateTable(int index)
{
	Table *t = findTable(index);
	if (!t)
		return;

	if (active_table != t){
		active_table = t;
		tableCaptionLabel->setText(t->objectName());
		table->clearContents();
		table->setRowCount(t->numCols());

		QStringList colNames = t->colNames();
		for (int i=0; i<table->rowCount(); i++ ){
			QTableWidgetItem *cell = new QTableWidgetItem(colNames[i].replace(",", "."));
			cell->setBackground (QBrush(Qt::lightGray));
			cell->setFlags (Qt::ItemIsEnabled);
			table->setItem(i, 0, cell);
			}

		for (int j=1; j < table->columnCount(); j++){
			for (int i=0; i < table->rowCount(); i++ )
				{
				QTableWidgetItem *cell = new QTableWidgetItem();
				cell->setBackground (QBrush(Qt::lightGray));
				table->setItem(i, j, cell);

				QCheckBox* cb = new QCheckBox(table);
				cb->installEventFilter(this);
				table->setCellWidget(i, j, cb);
				}
			}
		}
	updateColumnTypes();
}
开发者ID:kuzavas,项目名称:qtiplot,代码行数:35,代码来源:AssociationsDialog.cpp

示例3: updateTable

void AssociationsDialog::updateTable(int index)
{
  Table *t = findTable(index);
  if (!t)
    return;

  if (active_table != t)
  {
    active_table = t;
    tableCaptionLabel->setText(t->objectName());
    table->clearContents();
    table->setRowCount(t->numCols());

    QStringList colNames = t->colNames();
    // this vector will tell which rows should be disabled (cause there's no data in them)
    std::vector<bool> disableRow;
    disableRow.resize(table->rowCount(), false);
    for (int i=0; i<table->rowCount(); i++ )
    {
      QTableWidgetItem *cell = new QTableWidgetItem(colNames[i]);
      cell->setBackground (QBrush(Qt::lightGray));
      cell->setFlags (Qt::ItemIsEnabled);
      table->setItem(i, 0, cell);

      // do we need to disable this row cause the corresponding curve it's empty?
      // (empty curves could cause crashes in many other places)
      bool allEmpty = true;
      // Note possible confusion, here 'table' is the table that you see in the AssociationsDialog,
      // whereas t is the underlying data table (spreadsheet).
      for (int dataRow = 0; dataRow < t->numRows() && allEmpty; dataRow++)
      {
        // use i (row in the associations table) as column index
        allEmpty = allEmpty & t->text(dataRow, i).isEmpty();
      }
      if (allEmpty)
        disableRow[i] = true;
    }

    for (int j=1; j < table->columnCount(); j++)
    {
      for (int i=0; i < table->rowCount(); i++ )
      {
          QTableWidgetItem *cell = new QTableWidgetItem();
          cell->setBackground(QBrush(Qt::lightGray));
          cell->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
          table->setItem(i, j, cell);

          // disable (but keep the checkbox, as set above)
          if (disableRow[i])
            cell->setFlags(Qt::NoItemFlags);
      }
    }
  }
  updateColumnTypes();
}
开发者ID:dezed,项目名称:mantid,代码行数:55,代码来源:AssociationsDialog.cpp

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

示例5: setBackground

 int TableWidgetItem::setBackground ( lua_State * L )// ( const QBrush & brush )void
 {
	QTableWidgetItem* lhs = ValueInstaller2<QTableWidgetItem>::check( L, 1 );
	QBrush* brush = ValueInstaller2<QBrush>::check( L, 2 );
	lhs->setBackground( *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: 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

示例8: tagColorChanged

void
TagColorEditor::cellDoubleClicked(int row, int col)
{
  if (row == 0 && col > 0)
    return;

  QTableWidgetItem *item = table->item(row, col);
  uchar *colors = Global::tagColors();

  //int index = row*8 + col;
  int index = 0;
  if (row > 0) index = 1 + (row-1)*5 + col;

  QColor clr = QColor(colors[4*index+0],
		      colors[4*index+1],
		      colors[4*index+2]);
  clr = DColorDialog::getColor(clr);
  if (!clr.isValid())
    return;

  colors[4*index+0] = clr.red();
  colors[4*index+1] = clr.green();
  colors[4*index+2] = clr.blue();
  item->setData(Qt::DisplayRole, QString("%1").arg(index));
  item->setBackground(clr);

  emit tagColorChanged();
}
开发者ID:drancom,项目名称:drishti,代码行数:28,代码来源:tagcoloreditor.cpp

示例9: getCustomsfields

// load AWD_customs_field_list und im Dialog anzeigen
// --------------------------------------------------
void admin::getCustomsfields()
{
    QString y;
    QSqlQuery query;
    qy = "SELECT id,atype,adiftype FROM wawdlist WHERE aset !='0' ORDER BY id";
    query.exec(qy);
    row = query.size();                     // anzahl aedTypen
    customsTable->setRowCount(row);         // TabellenLänge setzen - col ist schon gesetzt
    row = 0;
    customsTable->setColumnWidth(0,63); 
    customsTable->setColumnWidth(1,160); 
    QBrush brush(QColor(217,207,196)); 
    while(query.next()) {
      z = 0;
      r = 0;
      col = 0;
      i = 0;
      y = query.value(i++).toString();
      QTableWidgetItem *rowItem = new QTableWidgetItem(tr("%1").arg((r++)*(z++))); //idn
      rowItem->setText(y);
      customsTable->setVerticalHeaderItem(row,rowItem);
      QTableWidgetItem *newItem = new QTableWidgetItem(tr("%1").arg((row)*(col)));//dbFeld
      newItem->setText(query.value(i++).toString());
      customsTable->setItem(row,col++,newItem);
      newItem->setBackground(brush);
      newItem = new QTableWidgetItem((tr("%1").arg((row)*(col))));                 // ADIF_name
      newItem->setText(query.value(i).toString());
      customsTable->setItem(row,col++,newItem);
      row++;
    }
}
开发者ID:frohro,项目名称:qtlog,代码行数:33,代码来源:adminCb.cpp

示例10: add

void QEditAssessment::add()
{
    Question q;

    questionList.append(q);

    // Append to question table
    int j = questionTable->rowCount();
    questionTable->insertRow(j);
    //questionTable->setRowHeight(j, 90);

    QTableWidgetItem *item = new QTableWidgetItem(QString::number(j+1));
    item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
    item->setTextAlignment(Qt::AlignHCenter);
    questionTable->setItem(j, 0, item);

    for (int i=1; i<7 ; i++)
    {
        item = new QTableWidgetItem;
        item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable);
        item->setTextAlignment(Qt::AlignHCenter);
        item->setBackground(QBrush(QColor(255, 255, 255)));
        questionTable->setItem(j, i, item);
    }
}
开发者ID:pLiuYang,项目名称:Anatomy-Annotator,代码行数:25,代码来源:qeditassessment.cpp

示例11: highlight

void VideoWindow::highlight(int ms)
{
    for(int r=0; r < this->eventsPositionInMiliseconds.size(); r++){
        QTableWidgetItem* item = this->ui->sequence->item(r,0);
        if(this->eventsPositionInMiliseconds.at(r) <= ms+125){
            if(this->eventsPositionInMiliseconds.at(r) >= ms-125)  item->setBackgroundColor(Qt::green);
            else item->setBackgroundColor(QColor(153,255,255));
        } else {
            QPalette p;
            if(r%2==0)
                item->setBackground(p.base());
            else
                item->setBackground(p.alternateBase());
        }
    }
}
开发者ID:gavaza,项目名称:pacca,代码行数:16,代码来源:videowindow.cpp

示例12: fnt

void
TagColorEditor::setColors()
{
  QFont fnt("Helvetica", 12);

  uchar *colors = Global::tagColors();
  for (int i=0; i < 256; i++)
    {      
      int row = i/2;
      int col = i%2; 

      int r,g,b;
      float a;

      r = colors[4*i+0];
      g = colors[4*i+1];
      b = colors[4*i+2];

      QTableWidgetItem *colorItem = table->item(row, col);
      if (!colorItem)
	{
	  colorItem = new QTableWidgetItem;
	  table->setItem(row, col, colorItem);
	}

      colorItem->setFont(fnt);
      colorItem->setData(Qt::DisplayRole, QString("%1").arg(i));
      if (colors[4*i+3] > 250)
	colorItem->setCheckState(Qt::Checked);
      else
	colorItem->setCheckState(Qt::Unchecked);
      colorItem->setBackground(QColor(r,g,b));
    }
}
开发者ID:nci,项目名称:drishti,代码行数:34,代码来源:tagcoloreditor.cpp

示例13: setItem

QTableWidgetItem* SessionTimesWidget::setItem(int row, int col, QString text, Qt::ItemFlags flags, int align,
        QColor textColor, QBrush background)
{
    if (ui->timesTableWidget->rowCount() <= row)
    {
        ui->timesTableWidget->insertRow(row);

//        for (int i = 0; i < ui->timesTableWidget->columnCount();  ++i)
//        {
//            if (i != col)
//                ui->timesTableWidget->setItem(row, i, new QTableWidgetItem());
//        }
    }

    QTableWidgetItem *item = ui->timesTableWidget->item(row, col);
    if (!item)
    {
        item = new QTableWidgetItem(text);
        item->setFlags(flags);
        ui->timesTableWidget->setItem(row, col, item);
    }
    item->setTextAlignment(align);
    item->setBackground(background);
    item->setText(text);
    item->setTextColor(textColor);

    return item;
}
开发者ID:johnny5tw,项目名称:f1lt,代码行数:28,代码来源:sessiontimeswidget.cpp

示例14: qDebug

void CQArrayAnnotationsWidget::fillTable1(size_t rowIndex,
    const CCopasiAbstractArray::index_type & index)
{
#ifdef DEBUG_UI
  qDebug() << "-- in fillTable0 B -- \n";
#endif

  if (!mpArray) return;

  assert(rowIndex < index.size());

  mpContentTable->setColumnCount(1);
  mpContentTable->setRowCount((int) mpArray->size()[rowIndex]);

  mpContentTable->setHorizontalHeaderItem(0, new QTableWidgetItem(""));

  size_t i, imax = mpArray->size()[rowIndex];

  CCopasiAbstractArray::index_type Index = index;

  //automatic color scaling
  if (mAutomaticColorScaling)
    {
      mpColorScale->startAutomaticParameterCalculation();

      for (i = 0; i < imax; ++i)
        {
          Index[rowIndex] = i;
          mpColorScale->passValue((*mpArray->array())[Index]);
        }

      mpColorScale->finishAutomaticParameterCalculation();
    }

  //table contents and annotations
  const std::vector<std::string> & rowdescr = mpArray->getAnnotationsString(rowIndex);

  for (i = 0; i < imax; ++i)
    {
      Index[rowIndex] = i;
      QTableWidgetItem * pItem = new QTableWidgetItem(FROM_UTF8(rowdescr[i]));
      mpContentTable->setVerticalHeaderItem((int) i, pItem);

      pItem = new QTableWidgetItem(QString::number((*mpArray->array())[Index]));
      mpContentTable->setItem((int) i, 0, pItem);

      if (mpColorScale != NULL)
        {
          pItem->setBackground(QBrush(mpColorScale->getColor((*mpArray->array())[Index])));
        }
    }

  mOneDimensional = true;

  mpContentTable->resizeRowsToContents();
  mpContentTable->resizeColumnsToContents();

  if (mpStack->currentIndex() == 1)
    fillBarChart();
}
开发者ID:sachiinb,项目名称:COPASI,代码行数:60,代码来源:CQArrayAnnotationsWidget.cpp

示例15: fillTable

void XMLProtocolParser::fillTable(std::string name, std::string inField)
{
    int row = this->gameData->refBox->tbl_info->rowCount();
    std::string team = "";
    if (cyan)
        team = cyanSetup[0];
    else if (magenta)
        team = magentaSetup[0];

    for (int i = 0; i < row; i++)
    {
        if (this->gameData->refBox->tbl_info->item(i, 0) == nullptr)
        {
            QTableWidgetItem *item = new QTableWidgetItem();
            item->setText(QString::fromStdString(team));
            this->gameData->refBox->tbl_info->setItem(i, 0, item);

            QTableWidgetItem *item1 = new QTableWidgetItem();
            item1->setText(QString::fromStdString(name));
            this->gameData->refBox->tbl_info->setItem(i, 1, item1);

            QTableWidgetItem *item2 = new QTableWidgetItem();
            item2->setText(QString::fromStdString(inField));
            this->gameData->refBox->tbl_info->setItem(i, 2, item2);

            QTableWidgetItem *item3 = new QTableWidgetItem();
            this->gameData->refBox->tbl_info->setItem(i, 3, item3);

            if (cyan)
            {
                item->setBackground(Qt::cyan);
                item1->setBackground(Qt::cyan);
                item2->setBackground(Qt::cyan);
                item3->setBackground(Qt::cyan);
            }
            else
            {
                item->setBackground(Qt::magenta);
                item1->setBackground(Qt::magenta);
                item2->setBackground(Qt::magenta);
                item3->setBackground(Qt::magenta);
            }

            break;
        }
    }
}
开发者ID:carpe-noctem-cassel,项目名称:cnc-msl,代码行数:47,代码来源:XMLProtocolParser.cpp


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