本文整理汇总了C++中QTableWidgetItem::setTextColor方法的典型用法代码示例。如果您正苦于以下问题:C++ QTableWidgetItem::setTextColor方法的具体用法?C++ QTableWidgetItem::setTextColor怎么用?C++ QTableWidgetItem::setTextColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTableWidgetItem
的用法示例。
在下文中一共展示了QTableWidgetItem::setTextColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fillInTable
void ResultWidget::fillInTable(int startIdx, QStringList data)
{
auto safeSetTableText = [&](int _row, int _col, QString _text)
{
QTableWidgetItem* tItem = ui->lowerTable->item(_row, _col);
if(tItem == nullptr)
{
tItem =new QTableWidgetItem();
ui->lowerTable->setItem(_row, _col, tItem);
}
tItem->setText(_text);
tItem->setTextAlignment(Qt::AlignCenter);
if(_text == "OK")
tItem->setTextColor(Qt::darkGreen);
else if(_text == "NG")
tItem->setTextColor(Qt::red);
};
int itemCounter = startIdx;
for(int i = 2; i <= 6; i++)
{
for(int j = 1; j <= 20; j++)
{
safeSetTableText(i, j, data[itemCounter]);
itemCounter++;
}
}
// ui->lowerTable->resizeColumnsToContents();
// ui->lowerTable->resizeRowsToContents();
}
示例2: 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();
}
示例3: creatSearchedItems
void MusicLrcSearchTableWidget::creatSearchedItems(const QString &songname,
const QString &artistname, const QString &time)
{
int count;
setRowCount(count = m_downLoadManager->getSongIdIndex());
QTableWidgetItem *item = new QTableWidgetItem;
item->setData(MUSIC_CHECK_ROLE, false);
setItem(count - 1, 0, item);
item = new QTableWidgetItem;
item->setText(QFontMetrics(font()).elidedText(songname, Qt::ElideRight, 170));
item->setTextColor(QColor(50, 50, 50));
item->setTextAlignment(Qt::AlignCenter);
item->setToolTip(songname);
setItem(count - 1, 1, item);
item = new QTableWidgetItem;
item->setText(QFontMetrics(font()).elidedText(artistname, Qt::ElideRight, 144));
item->setTextColor(QColor(50, 50, 50));
item->setTextAlignment(Qt::AlignCenter);
item->setToolTip(artistname);
setItem(count - 1, 2, item);
item = new QTableWidgetItem(time);
item->setTextColor(QColor(50, 50, 50));
item->setTextAlignment(Qt::AlignCenter);
setItem(count - 1, 3, item);
item = new QTableWidgetItem;
item->setIcon(QIcon(QString::fromUtf8(":/radio/collect")));
setItem(count - 1, 4, item);
}
示例4: creatSearchedItems
void MusicLrcSearchTableWidget::creatSearchedItems(const QString &songname,
const QString &artistname, const QString &time)
{
int count;
setRowCount(count = m_downLoadManager->getSongIdIndex());
setStyleSheet(MusicUIObject::MTableWidgetStyle01 + \
MusicUIObject::MScrollBarStyle01);
QTableWidgetItem *item = new QTableWidgetItem;
item->setData(Qt::DisplayRole, false);
setItem(count - 1, 0, item);
item = new QTableWidgetItem(songname);
item->setTextColor(QColor(50, 50, 50));
item->setTextAlignment(Qt::AlignCenter);
item->setToolTip(songname);
setItem(count - 1, 1, item);
item = new QTableWidgetItem(artistname);
item->setTextColor(QColor(50, 50, 50));
item->setTextAlignment(Qt::AlignCenter);
item->setToolTip(artistname);
setItem(count - 1, 2, item);
item = new QTableWidgetItem(time);
item->setTextColor(QColor(50, 50, 50));
item->setTextAlignment(Qt::AlignCenter);
setItem(count - 1, 3, item);
item = new QTableWidgetItem(QIcon(QString::fromUtf8(":/radio/collect")), "");
item->setTextAlignment(Qt::AlignCenter);
setItem(count - 1, 4, item);
}
示例5: replacePlayWidgetRow
void MusicSongsListWidget::replacePlayWidgetRow()
{
if(m_playRowIndex >= rowCount() || m_playRowIndex < 0)
{
m_playRowIndex = 0;
}
QString name = !m_musicSongs->isEmpty() ? m_musicSongs->at(m_playRowIndex).getMusicName() : QString();
setRowHeight(m_playRowIndex, 30);
removeCellWidget(m_playRowIndex, 0);
removeCellWidget(m_playRowIndex, 1);
removeCellWidget(m_playRowIndex, 2);
delete takeItem(m_playRowIndex, 0);
delete takeItem(m_playRowIndex, 1);
delete takeItem(m_playRowIndex, 2);
QTableWidgetItem *item = new QTableWidgetItem;
setItem(m_playRowIndex, 0, item);
item = new QTableWidgetItem(QFontMetrics(font()).elidedText(name, Qt::ElideRight, 242));
item->setTextColor(QColor(50, 50, 50));
item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
setItem(m_playRowIndex, 1, item);
item = new QTableWidgetItem( (*m_musicSongs)[m_playRowIndex].getMusicTime() );
item->setTextColor(QColor(50, 50, 50));
item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
setItem(m_playRowIndex, 2, item);
delete m_musicSongsPlayWidget;
m_musicSongsPlayWidget = nullptr;
}
示例6: updateHexTable
void MainWindow::updateHexTable(int pos)
{
QTableWidgetItem *item = wgtHexTable->item(pos / 16, pos % 16);
item->setText(eep.mid(pos, 1).toHex().toUpper());
if (item->text() == "FF")
item->setTextColor(Qt::gray);
else if (item->text() == "00" && (pos) >= EEPROM_LABELS)
item->setTextColor(Qt::blue);
else
item->setTextColor(Qt::black);
}
示例7: receiveDataFinshed
void MusicCloudSharedSongTableWidget::receiveDataFinshed(const QNDataItems &items)
{
clear();
int count = items.count();
if(count == 0)
{
emit updateLabelMessage(tr("List Is Empty!"));
createUploadFileWidget();
return;
}
delete m_openFileWidget;
m_openFileWidget = nullptr;
setRowCount(count);
QHeaderView *headerview = horizontalHeader();
for(int i=0; i<count; ++i)
{
QNDataItem dataItem = items[i];
QTableWidgetItem *item = new QTableWidgetItem;
item->setData(MUSIC_DATAS_ROLE, QVariant::fromValue<QNDataItem>(dataItem));
setItem(i, 0, item);
item = new QTableWidgetItem;
item->setToolTip(dataItem.m_name);
item->setText(MusicUtils::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerview->sectionSize(1) - 20));
item->setTextColor(QColor(MusicUIObject::MColorStyle12_S));
item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
setItem(i, 1, item);
item = new QTableWidgetItem;
item->setToolTip(MusicUtils::Number::size2Label(dataItem.m_size));
item->setText(MusicUtils::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerview->sectionSize(2) - 5));
item->setTextColor(QColor(MusicUIObject::MColorStyle12_S));
item->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
setItem(i, 2, item);
///insert server datas into caches
MusicUploadData data;
data.m_path = dataItem.m_name.trimmed();
data.m_name = data.m_path;
data.m_state = MusicUploadData::Successed;
if(!m_waitedFiles.contains(data))
{
m_waitedFiles << data;
}
}
m_currentUploadIndex = m_waitedFiles.count();
emit updateLabelMessage(tr("List Update Finished!"));
}
示例8: creatSearchedItems
void MusicVideoTableWidget::creatSearchedItems(const QString &songname,
const QString &artistname,
const QString &time)
{
int count;
setRowCount(count = m_downLoadManager->getSongIdIndex());
QHeaderView *headerview = horizontalHeader();
QTableWidgetItem *item = new QTableWidgetItem;
item->setData(MUSIC_CHECK_ROLE, false);
setItem(count - 1, 0, item);
item = new QTableWidgetItem;
item->setText(QFontMetrics(font()).elidedText(songname, Qt::ElideRight,
headerview->sectionSize(1) - 5));
item->setTextColor(QColor(50, 50, 50));
item->setTextAlignment(Qt::AlignCenter);
item->setToolTip(songname);
setItem(count - 1, 1, item);
item = new QTableWidgetItem;
item->setText(QFontMetrics(font()).elidedText(artistname, Qt::ElideRight,
headerview->sectionSize(2) - 5));
item->setTextColor(QColor(50, 50, 50));
item->setTextAlignment(Qt::AlignCenter);
item->setToolTip(artistname);
setItem(count - 1, 2, item);
item = new QTableWidgetItem;
item->setIcon(QIcon(randToGetStrength()));
setItem(count - 1, 3, item);
item = new QTableWidgetItem(time);
item->setTextColor(QColor(50, 50, 50));
item->setTextAlignment(Qt::AlignCenter);
setItem(count - 1, 4, item);
item = new QTableWidgetItem;
item->setIcon(QIcon(QString::fromUtf8(":/share/showMV")));
setItem(count - 1, 5, item);
item = new QTableWidgetItem;
item->setIcon(QIcon(QString::fromUtf8(":/share/autionplay")));
setItem(count - 1, 6, item);
item = new QTableWidgetItem;
item->setIcon(QIcon(QString::fromUtf8(":/share/musicdownload")));
setItem(count - 1, 7, item);
}
示例9: 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();
}
示例10: 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)));
}
示例11: updateStudentTable
void ExamControl::updateStudentTable(QList<Student *> students)
{
int numberLogin = 0;
int numbersubmit = 0;
tableWidget_student->setRowCount(students.count());
for(int i = 0; i < students.count(); ++i){
if(students.at(i)->getState() != QString("未登录"))
numberLogin++;
else if(students.at(i)->getState() == QString("已经交卷"))
numbersubmit++;
QTableWidgetItem *hostname = new QTableWidgetItem(students.at(i)->getHostname());
QTableWidgetItem *id = new QTableWidgetItem(students.at(i)->getID());
QTableWidgetItem *name = new QTableWidgetItem(students.at(i)->getName());
QTableWidgetItem *grade = new QTableWidgetItem(QString::number(students.at(i)->getGrade()));
QTableWidgetItem *_class = new QTableWidgetItem(QString::number(students.at(i)->getClass()));
QTableWidgetItem *state = new QTableWidgetItem(students.at(i)->getState());
if(state->text() == QString("未登录"))
{
state->setTextColor(QColor("red"));
}
tableWidget_student->setItem(i, 0, hostname);
tableWidget_student->setItem(i, 1, id);
tableWidget_student->setItem(i, 2, name);
tableWidget_student->setItem(i, 3, grade);
tableWidget_student->setItem(i, 4, _class);
tableWidget_student->setItem(i, 5, state);
}
label_studentcount->setText(QString("共有%1名学生 已登录%2人 已交卷%3人").arg(students.count()).arg(numberLogin).arg(numbersubmit));
}
示例12: 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());
}
示例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;
}
示例14: createSearchedItem
void MusicLrcSearchTableWidget::createSearchedItem(const MusicSearchedItem &songItem)
{
int count = rowCount();
setRowCount(count + 1);
QHeaderView *headerview = horizontalHeader();
QTableWidgetItem *item = new QTableWidgetItem;
item->setData(MUSIC_CHECK_ROLE, false);
setItem(count, 0, item);
item = new QTableWidgetItem;
item->setToolTip(songItem.m_songName);
item->setText(MusicUtils::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerview->sectionSize(1) - 20));
item->setTextColor(QColor(100, 100, 100));
item->setTextAlignment(Qt::AlignCenter);
setItem(count, 1, item);
item = new QTableWidgetItem;
item->setToolTip(songItem.m_singerName);
item->setText(MusicUtils::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerview->sectionSize(2) - 20));
item->setTextColor(QColor(100, 100, 100));
item->setTextAlignment(Qt::AlignCenter);
setItem(count, 2, item);
item = new QTableWidgetItem(songItem.m_time);
item->setTextColor(QColor(100, 100, 100));
item->setTextAlignment(Qt::AlignCenter);
setItem(count, 3, item);
item = new QTableWidgetItem;
item->setIcon(QIcon(randToGetStrength()));
setItem(count, 4, item);
item = new QTableWidgetItem;
item->setIcon(QIcon(":/tiny/lb_server_type"));
item->setToolTip(songItem.m_type);
setItem(count, 5, item);
item = new QTableWidgetItem;
item->setIcon(QIcon(":/contextMenu/btn_download"));
setItem(count, 6, item);
}
示例15: creatSearchedItems
void MusicSongSearchOnlineTableWidget::creatSearchedItems(const QString &songname,
const QString &artistname, const QString &time)
{
int count;
setRowCount(count = m_downLoadManager->getSongIdIndex());
QTableWidgetItem *item = new QTableWidgetItem;
item->setData(MUSIC_CHECK_ROLE, false);
item->setData(MUSIC_AUDIT_ROLE, AUDITION_STOP);
setItem(count - 1, 0, item);
item = new QTableWidgetItem;
item->setText(QFontMetrics(font()).elidedText(songname, Qt::ElideRight, 220));
item->setTextColor(QColor(50, 50, 50));
item->setTextAlignment(Qt::AlignCenter);
item->setToolTip(songname);
setItem(count - 1, 1, item);
item = new QTableWidgetItem;
item->setText(QFontMetrics(font()).elidedText(artistname, Qt::ElideRight, 170));
item->setTextColor(QColor(50, 50, 50));
item->setTextAlignment(Qt::AlignCenter);
item->setToolTip(artistname);
setItem(count - 1, 2, item);
item = new QTableWidgetItem(time);
item->setTextColor(QColor(50, 50, 50));
item->setTextAlignment(Qt::AlignCenter);
setItem(count - 1, 3, item);
item = new QTableWidgetItem;
item->setIcon(QIcon(QString::fromUtf8(":/image/addtoplaylist")));
setItem(count - 1, 4, item);
item = new QTableWidgetItem;
item->setIcon(QIcon(QString::fromUtf8(":/share/musicdownload")));
setItem(count - 1, 5, item);
}