本文整理汇总了C++中QTableWidgetItem::setBackgroundColor方法的典型用法代码示例。如果您正苦于以下问题:C++ QTableWidgetItem::setBackgroundColor方法的具体用法?C++ QTableWidgetItem::setBackgroundColor怎么用?C++ QTableWidgetItem::setBackgroundColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTableWidgetItem
的用法示例。
在下文中一共展示了QTableWidgetItem::setBackgroundColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: listUpdate_slot
void QKeyValueListView::listUpdate_slot(void)
{
int i, n;
ListMap::iterator it;
QColor clCL1, clCL2;
QColor clB1, clB2;
int fontSize = 8;
int rowHeight = 20;
clCL1 = QColor(0x00, 0x00, 0xFF);
clCL2 = QColor(0x00, 0x00, 0x00);
clB1 = QColor(0xFF, 0xFF, 0xFF);
clB2 = QColor(0xE0, 0xE0, 0xE0);
m_mutex->lock();
n = m_data.size();
setRowCount(n);
setColumnCount(2);
for(i=0, it=m_data.begin(); it!=m_data.end(); i++, it++) {
// set name cell
if( this->item(i, 0) != NULL ) {
this->item(i, 0)->setText(it.key());
} else {
QTableWidgetItem* item = new QTableWidgetItem();
item->setText(it.key());
item->setTextColor(clCL1);
if( i % 2 == 0 ) item->setBackgroundColor(clB1);
else item->setBackgroundColor(clB2);
item->setFont(QFont("", fontSize));
this->setItem(i, 0, item);
}
// set value cell
if( this->item(i, 1) != NULL ) {
this->item(i, 1)->setText(it.value());
} else {
QTableWidgetItem* item = new QTableWidgetItem();
item->setText(it.value());
item->setTextColor(clCL2);
if( i % 2 == 0 ) item->setBackgroundColor(clB1);
else item->setBackgroundColor(clB2);
item->setFont(QFont("", fontSize));
this->setItem(i, 1, item);
}
setRowHeight(i, rowHeight);
}
m_mutex->unlock();
}
示例2: currentRowColumnChanged
void SearchResultWidget::currentRowColumnChanged(int currentRow, int /*currentColumn*/, int previousRow, int /*previousColumn*/)
{
if (currentRow == previousRow) {
return;
}
for (int col = 0; col < 3; ++col) {
QTableWidgetItem* previousRowItem = searchTable->item(previousRow, col);
QTableWidgetItem* currentRowItem = searchTable->item(currentRow, col);
if (previousRowItem && col != 0) {
QColor color = previousRowItem->data(Qt::UserRole + 15).value<QColor>();
if (color.isValid()) {
previousRowItem->setBackgroundColor(color);
}
}
if (currentRowItem) {
QString text = currentRowItem->text();
if (col == 2 && !viewedItems.contains(text)) {
viewedItems << text;
}
currentRowItem->setData(Qt::UserRole + 15, currentRowItem->backgroundColor());
currentRowItem->setBackgroundColor(QColor(Qt::green).lighter(170));
}
}
}
示例3: tableUpdate
//刷新表格
void PlayList::tableUpdate()
{
//这里不能调用此类中任何一个操作元素的函数
//否则将造成循环递归
ui->playListTable->clear();
ui->playListTable->setRowCount(getLength());//删除项目后,更改表格总行数,防止出现空白行。
int count = fileList.size();//循环效率优化
//重新生成表格项目
for (int i = 0; i < count; i++)
{
QString fileName = fileList[i];
QFileInfo fileInfo(fileName);
QTableWidgetItem *item = new QTableWidgetItem(fileInfo.fileName());
QTableWidgetItem *timeItem = new QTableWidgetItem(timeList[i]);
if (i == curIndex)
{
item->setBackgroundColor(QColor(128, 255, 0, 128));
timeItem->setBackgroundColor(QColor(128, 255, 0, 128));
}
ui->playListTable->setItem(i, 0, item);
ui->playListTable->setItem(i, 1, timeItem);
}
}
示例4: setStatus
void DetailsViewer::setStatus(const DNSData *data) {
QString recordType = data->recordType();
QColor color = m_node->getColorForStatus(data->DNSSECStatus()).lighter(175);
QTableWidgetItem *item = m_rows[recordType]->status;
item->setBackgroundColor(color);
item->setText(data->DNSSECStringStatuses().join(", "));
item = m_rows[recordType]->data;
item->setBackgroundColor(color);
item->setText(QStringList(data->data()).join(",\n"));
m_rows[recordType]->label->setBackgroundColor(color);
}
示例5: updateColors
void StochasticProcessWidget::updateColors() {
int distCount = process->getNumStates();
QColor weakestDistColor;
QColor weakDistColor;
QColor avgDistColor;
QColor strongDistColor;
for (int i = 0; i < distCount; i++) {
int hueValue = (int)round(255.0
/ ((double)distCount / (double)i));
weakDistColor.setHsv(hueValue, 40, 245);
weakestDistColor.setHsv(hueValue, 15, 245);
avgDistColor.setHsv(hueValue, 100, 255);
strongDistColor.setHsv(hueValue, 150, 255);
QPen curvePen(QBrush(strongDistColor), 3.0,
Qt::SolidLine);
infCurves[i]->setPen(curvePen);
supCurves[i]->setPen(curvePen);
QPen avgPen(QBrush(avgDistColor), 3.0,
Qt::DashLine);
avgMarkers[i]->setLinePen(avgPen);
QPen stdDevPen(QBrush(avgDistColor), 3.0,
Qt::DotLine);
stdDevMarkers[i].first->setLinePen(stdDevPen);
stdDevMarkers[i].second->setLinePen(stdDevPen);
for (int j = 0; j <= 4; j++) {
distGraphTable->item(j, i)->setBackgroundColor(weakDistColor);
}
for (int j = 0; j < distTable->rowCount(); j++) {
QTableWidgetItem *item = distTable->item(j,
i);
if (item) {
if (item->text() == "0\n0") {
item->setBackgroundColor(weakestDistColor);
} else {
item->setBackgroundColor(weakDistColor);
}
}
}
}
distGraph->replot();
}
示例6: addTableRow
void VtkColorTable::addTableRow(int row, const Point & point) {
mainTable->insertRow(row);
QTableWidgetItem * newItem = new QTableWidgetItem(tr("%1").arg(point.scalarValue));
mainTable->setItem(row, 0, newItem);
newItem = new QTableWidgetItem(tr("%1").arg(point.color.red()));
mainTable->setItem(row, 1, newItem);
newItem = new QTableWidgetItem(tr("%1").arg(point.color.green()));
mainTable->setItem(row, 2, newItem);
newItem = new QTableWidgetItem(tr("%1").arg(point.color.blue()));
mainTable->setItem(row, 3, newItem);
newItem = new QTableWidgetItem();
newItem->setBackgroundColor(point.color);
newItem->setFlags(Qt::ItemIsEnabled);
mainTable->setItem(row, 4, newItem);
newItem = new QTableWidgetItem(tr("%1").arg(point.midpoint));
mainTable->setItem(row, 5, newItem);
newItem = new QTableWidgetItem(tr("%1").arg(point.sharpness));
mainTable->setItem(row, 6, newItem);
}
示例7: QTableWidget
TupLayerIndex::TupLayerIndex(int sceneIndex, QWidget *parent) : QTableWidget(0, 1, parent), k(new Private)
{
#ifdef K_DEBUG
TINIT;
#endif
k->sceneIndex = sceneIndex;
setSelectionMode(QAbstractItemView::SingleSelection);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
QTableWidgetItem *prototype = new QTableWidgetItem;
prototype->setTextAlignment(Qt::AlignCenter);
prototype->setBackgroundColor(palette().text().color());
prototype->setTextColor(palette().background().color());
setItemPrototype(prototype);
setHorizontalHeaderLabels(QStringList() << tr("Layers"));
verticalHeader()->hide();
setHorizontalHeader(new TupLayerIndexHeader(this));
setItemDelegate(new TupLayerIndexItemDelegate(this));
connect(this, SIGNAL(cellClicked(int, int)), this, SLOT(setLocalRequest(int, int)));
}
示例8: 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());
}
}
}
示例9: find
void LogEditorWindow::find()
{
clear();
// 0 = "Speed"
// 1 = "Heart rate"
// 2 = "Power"
// 3 = "Cadence"
// 4 = "Altitude"
// 5 = "Latitude"
// 6 = "Longitude"
// 7 = "Temperature"
const int index = _field_selection->currentIndex();
const double value = _search_value->value();
_search_result_indecies.clear();
for (int r=0; r < _table->rowCount(); ++r)
{
QTableWidgetItem* item = _table->item(r, index + 2);
if (searchComparison(item->text().toDouble(), value))
{
item->setBackgroundColor(Qt::red);
_search_result_indecies.push_back(r);
}
}
// Scroll to the first search result
if (_search_result_indecies.size() > 0)
{
_table->verticalScrollBar()->setValue(_search_result_indecies[0]);
}
_search_result_index = 0;
}
示例10: updateListingTrace
void ListingTracePane::updateListingTrace()
{
// tableWidget depends on whether we are in the OS or a program
QTableWidget *tableWidget;
if (Sim::trapped) {
tableWidget = ui->listingPepOsTraceTableWidget;
ui->listingPepOsTraceTableWidget->show();
ui->listingTraceTableWidget->hide();
}
else {
tableWidget = ui->listingTraceTableWidget;
ui->listingPepOsTraceTableWidget->hide();
ui->listingTraceTableWidget->show();
}
for (int i = highlightedItemList.size() - 1; i >= 0; i--) {
highlightedItemList.at(i)->setBackgroundColor(Qt::white);
highlightedItemList.at(i)->setTextColor(Qt::black);
highlightedItemList.removeLast();
}
if (Pep::memAddrssToAssemblerListing->contains(Sim::programCounter)) {
QTableWidgetItem *highlightedItem = tableWidget->item(Pep::memAddrssToAssemblerListing->value(Sim::programCounter), 1);
highlightedItem->setBackgroundColor(QColor(56, 117, 215));
highlightedItem->setTextColor(Qt::white);
highlightedItemList.append(highlightedItem);
tableWidget->scrollToItem(highlightedItem);
}
tableWidget->horizontalScrollBar()->setValue(tableWidget->horizontalScrollBar()->minimum());
}
示例11: 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);
}
示例12: updateTransitionColors
void StochasticProcessWidget::updateTransitionColors() {
int distCount = distGraphTable->columnCount() - 1;
QColor cellColor;
int rowLb = Lb(transitionMatrix, 1);
int colLb = Lb(transitionMatrix, 2);
for (int i = 0; i < distCount; i++) {
for (int j = 0; j
< transitionTable->columnCount(); j++) {
QTableWidgetItem *item =
transitionTable->item(i, j);
if (!item) {
continue;
}
double
value =
_double(mid(transitionMatrix[rowLb + i][colLb + j]));
int hueValue = (int)round(255.0
/ ((double)distCount / (double)i));
cellColor.setHsv(hueValue, (int)floor(90.0
* sqrt(value)), 255);
item->setBackgroundColor(cellColor);
}
}
}
示例13: addTextItemToBottomRow_
void SpectraIdentificationViewWidget::addTextItemToBottomRow_(const QString& text, Size column_index, const QColor& c)
{
QTableWidgetItem * item = table_widget_->itemPrototype()->clone();
item->setText(text);
item->setBackgroundColor(c);
table_widget_->setItem(table_widget_->rowCount() - 1, column_index, item);
}
示例14: addDoubleItemToBottomRow_
void SpectraIdentificationViewWidget::addDoubleItemToBottomRow_(const double d, Size column_index, const QColor& c)
{
QTableWidgetItem * item = table_widget_->itemPrototype()->clone();
item->setData(Qt::DisplayRole, d);
item->setBackgroundColor(c);
table_widget_->setItem(table_widget_->rowCount() - 1, column_index, item);
}
示例15: setDebuggingState
void ListingTracePane::setDebuggingState(bool b)
{
QTableWidget *tableWidget;
if (Sim::trapped) {
tableWidget = ui->listingPepOsTraceTableWidget;
ui->listingPepOsTraceTableWidget->show();
ui->listingTraceTableWidget->hide();
}
else {
tableWidget = ui->listingTraceTableWidget;
ui->listingPepOsTraceTableWidget->hide();
ui->listingTraceTableWidget->show();
}
for (int i = 0; i < tableWidget->rowCount(); i++) {
tableWidget->item(i, 1)->setBackgroundColor(Qt::white);
tableWidget->item(i, 1)->setTextColor(Qt::black);
}
highlightedItemList.clear();
if (b && Pep::memAddrssToAssemblerListing->contains(Sim::programCounter)) {
QTableWidgetItem *highlightedItem = tableWidget->item(Pep::memAddrssToAssemblerListing->value(Sim::programCounter), 1);
highlightedItem->setBackgroundColor(QColor(56, 117, 215));
highlightedItem->setTextColor(Qt::white);
highlightedItemList.append(highlightedItem);
tableWidget->scrollToItem(highlightedItem);
}
tableWidget->horizontalScrollBar()->setValue(tableWidget->horizontalScrollBar()->minimum());
// resizeDocWidth();
}