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


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

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


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

示例1: tableRollUpdate

void MainInterface::tableRollUpdate()
{
    unsigned int row = 0;
    unsigned int column = 0;
    if(table_state == TABLE_SHOW){
        if(spark_info->b_array[B_SELECT]){
            for(row = 0;row < abs(model->rowCount());row++){
                QBrush brush;
                if(row == spark_info->uint_array[UINT_CURRENT_ROM]){
                    brush = QBrush(SELECT_COLOR);
                }
                else if(row < spark_info->uint_array[UINT_START_ROW]){
                    brush = QBrush(UNSELECT_COLOR);
                }
                else if(row < spark_info->uint_array[UINT_CURRENT_ROM]){
                    brush = QBrush(OK_COLOR);
                }
                else if(row <= spark_info->uint_array[UINT_END_ROW]){
                    brush = QBrush(UNOK_COLOR);
                }
                else{
                    brush = QBrush(UNSELECT_COLOR);
                }
                for(column = 0;column < 11;column ++){
                    QStandardItem* item = model->item(row ,column);
                    item->setBackground(brush);
                }
            }
        }
        /*没有加工选择 */
        else{
            for(row = 0;row < abs(model->rowCount());row++){
                QBrush brush;
                brush = QBrush(UNSELECT_COLOR);
                for(column = 0;column < 11;column ++){
                    QStandardItem* item = model->item(row ,column);
                    item->setBackground(brush);
                }
            }
        }
    }
    else if(table_state == TABLE_SELECT||table_state == TABLE_DELETE||table_state == TABLE_EDIT||table_state == TABLE_ADD){
        for(row = 0;row < abs(model->rowCount());row++){
            QBrush brush;
            if(row < spark_info->uint_array[UINT_START_ROW]){
                brush = QBrush(UNSELECT_COLOR);
            }
            else if(row <= spark_info->uint_array[UINT_END_ROW]){
                brush = QBrush(UNOK_COLOR);
            }
            else{
                brush = QBrush(UNSELECT_COLOR);
            }
            for(column = 0;column < 11;column ++){
                QStandardItem* item = model->item(row ,column);
                item->setBackground(brush);
            }
        }
    }
}
开发者ID:taiyuankejizhu,项目名称:SparkZNC,代码行数:60,代码来源:maininterface.cpp

示例2: updateTimes

void QNode::updateTimes()
{
  double time;
  QStandardItem* node;

  if(m_currentTabText == "System Info")
  {
    for(int i = 0; i < m_safeSpeedModel.rowCount(); i++)
    {
      if( (node = m_safeSpeedModel.item(i,2)) == 0 || !node->data().isValid())
      {
        ROS_ERROR("Invalid safespeed child");
      } else
      {
        time = ros::Time::now().toSec()-node->data().toDouble();
        node->setText(QString::number(time, 'g', 4));
        //set colors for stale
        if(time > m_safeSpeedTimeout)
        {
          node->setBackground(Qt::magenta);
        } else
        {
          node->setBackground(m_safeSpeedModel.item(i,1)->background());
        }
      }
    }
  }
}
开发者ID:AmitShah,项目名称:autorally,代码行数:28,代码来源:qnode.cpp

示例3: QColor

QStandardItem *EquipmentColumn::build_cell(Dwarf *d){
    QStandardItem *item = init_cell(d);

    QColor rating_color = QColor(69,148,21);
    float rating =  d->get_uniform_rating();
    float coverage = d->get_coverage_rating();

    if(coverage < 100){ //prioritize coverage
        rating = coverage;
        rating_color = Item::color_uncovered();
    }else{
        if(rating < 100) //missing uniform items
            rating_color = Item::color_missing();
    }

    float sort_val = rating - d->get_inventory_wear();
    item->setData(d->get_inventory_wear(),DwarfModel::DR_SPECIAL_FLAG);
    item->setBackground(QBrush(rating_color));
    item->setData(CT_EQUIPMENT, DwarfModel::DR_COL_TYPE);
    item->setData(rating, DwarfModel::DR_RATING); //other drawing 0-100
    item->setData(sort_val, DwarfModel::DR_SORT_VALUE);
    set_export_role(DwarfModel::DR_RATING);

    QString tooltip = QString("<center><h3>%1</h3></center>%2%3")
            .arg(m_title)
            .arg(build_tooltip_desc(d))
            .arg(tooltip_name_footer(d));

    item->setToolTip(tooltip);
    return item;
}
开发者ID:perturbation,项目名称:Dwarf-Therapist,代码行数:31,代码来源:equipmentcolumn.cpp

示例4: AddProgram

bool ProgramsModel::AddProgram(int groupNum, QModelIndex &index, int row)
{
    QStandardItem *groupItem = item(groupNum);

    //if the group was disabled re-enable it
    if(groupItem->rowCount()==0) {
        groupItem->setBackground(Qt::transparent);
        groupItem->setToolTip("");
    }

    int progId = myHost->programsModel->GetNextProgId();

    QString name("New prog");

    //create the program item
    QStandardItem *prgItem = new QStandardItem( name );
    prgItem->setData(ProgramNode,NodeType);
    prgItem->setData(progId,ProgramId);
#ifndef QT_NO_DEBUG
    prgItem->setData(progId,Qt::ToolTipRole);
#endif
    prgItem->setDragEnabled(true);
    prgItem->setDropEnabled(false);
    prgItem->setEditable(true);

    if(row==-1)
        row=groupItem->rowCount();
    groupItem->insertRow(row, prgItem);

    index = prgItem->index();

//    ValidateProgChange(index);

    return true;
}
开发者ID:eriser,项目名称:vstboard-1,代码行数:35,代码来源:programsmodel.cpp

示例5: addStandardItemWithCss

void m_table::addStandardItemWithCss(int line, int coll,QString val,QString css){

    QStandardItem * tmpItem = new QStandardItem(QString(val));
    //tmpItem->setForeground(Qt::gray);
    tmpItem->setBackground(Qt::gray);
    model->setItem(line, coll, tmpItem);
}
开发者ID:Kiwhacks,项目名称:AlgoTeX,代码行数:7,代码来源:m_table.cpp

示例6: updateChannelConfig

void ChannelConfigModel::updateChannelConfig(const SongFormat *currentFormat)
{
    this->removeRows(0, this->rowCount());

    this->currentFormat = currentFormat;
    if(currentFormat == nullptr)
    {
        return;
    }

    this->setRowCount(currentFormat->Voices);
    for (int i = 0; i < currentFormat->Voices; i++)
    {
        const std::string &voiceName = currentFormat->VoiceName[i];
        QStandardItem *item = new QStandardItem(QString::fromStdString(voiceName));

        QBrush b(currentFormat->VoiceIsMuted[i] ? Qt::red : Qt::green);
        item->setBackground(b);

        QBrush f(currentFormat->VoiceIsMuted[i] ? Qt::white : Qt::black);
        item->setForeground(f);

        item->setTextAlignment(Qt::AlignCenter);
        item->setCheckable(false);
        item->setCheckState(currentFormat->VoiceIsMuted[i] ? Qt::Unchecked : Qt::Checked);
        this->setItem(i, 0, item);
    }
}
开发者ID:derselbst,项目名称:ANMP,代码行数:28,代码来源:ChannelConfigModel.cpp

示例7: clone

void tst_QStandardItem::clone()
{
    QStandardItem item;
    item.setText(QLatin1String("text"));
    item.setToolTip(QLatin1String("toolTip"));
    item.setStatusTip(QLatin1String("statusTip"));
    item.setWhatsThis(QLatin1String("whatsThis"));
    item.setSizeHint(QSize(64, 48));
    item.setFont(QFont());
    item.setTextAlignment(Qt::AlignLeft|Qt::AlignVCenter);
    item.setBackground(QColor(Qt::blue));
    item.setForeground(QColor(Qt::green));
    item.setCheckState(Qt::PartiallyChecked);
    item.setAccessibleText(QLatin1String("accessibleText"));
    item.setAccessibleDescription(QLatin1String("accessibleDescription"));
    item.setFlags(Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);

    QStandardItem *clone = item.clone();
    QCOMPARE(clone->text(), item.text());
    QCOMPARE(clone->toolTip(), item.toolTip());
    QCOMPARE(clone->statusTip(), item.statusTip());
    QCOMPARE(clone->whatsThis(), item.whatsThis());
    QCOMPARE(clone->sizeHint(), item.sizeHint());
    QCOMPARE(clone->font(), item.font());
    QCOMPARE(clone->textAlignment(), item.textAlignment());
    QCOMPARE(clone->background(), item.background());
    QCOMPARE(clone->foreground(), item.foreground());
    QCOMPARE(clone->checkState(), item.checkState());
    QCOMPARE(clone->accessibleText(), item.accessibleText());
    QCOMPARE(clone->accessibleDescription(), item.accessibleDescription());
    QCOMPARE(clone->flags(), item.flags());
    QVERIFY(!(*clone < item));
    delete clone;
}
开发者ID:maxxant,项目名称:qt,代码行数:34,代码来源:tst_qstandarditem.cpp

示例8: addItems

void RegistersModel::addItems(int startAddress, int noOfItems, bool valueIsEditable)
{
    int row;
    int col;
    m_startAddress = startAddress;
    m_noOfItems = noOfItems;
    m_offset = (startAddress % 10);
    m_firstRow = startAddress / 10;
    m_lastRow = (startAddress + noOfItems - 1) / 10;

    qDebug()<<  "RegistersModel : address " << startAddress << " ,noOfItems " << noOfItems
                << " ,offset " << m_offset << " ,first row " << m_firstRow << " ,last row " << m_lastRow;

    //Format Vertical - Horizontal Header
    clear();
    if (noOfItems > 1) {
        model->setHorizontalHeaderLabels(QStringList()<<RegModelHeaderLabels[0]<<RegModelHeaderLabels[1]
                                                    <<RegModelHeaderLabels[2]<<RegModelHeaderLabels[3]
                                                    <<RegModelHeaderLabels[4]<<RegModelHeaderLabels[5]
                                                    <<RegModelHeaderLabels[6]<<RegModelHeaderLabels[7]
                                                    <<RegModelHeaderLabels[8]<<RegModelHeaderLabels[9]);

        QStringList vertHeader;
        for (int i = m_firstRow; i <= m_lastRow ; i++) {
            vertHeader<<QString("%1").arg(i * 10, 2, 10, QLatin1Char('0'));
        }
        model->setVerticalHeaderLabels(vertHeader);
    }
    else {
        model->setHorizontalHeaderLabels(QStringList()<<RegModelHeaderLabels[0]);
        model->setVerticalHeaderLabels(QStringList()<<QString("%1").arg(startAddress, 2, 10, QLatin1Char('0')));
    }

    //Add data to model
    if (noOfItems == 1){
        QStandardItem *valueItem = new QStandardItem("-");model->setItem(0, 0, valueItem);
        valueItem->setEditable(valueIsEditable);
    }
    else {
        for (int i = 0; i < ((m_offset + noOfItems - 1) / 10 + 1) * 10 ; i++) {
            row = i / 10;
            col = i % 10;
            //Address
            if (i >= m_offset + noOfItems || i < m_offset){//not used cells
                QStandardItem *valueItem = new QStandardItem("x");model->setItem(row, col, valueItem);
                valueItem->setEditable(false);
                valueItem->setForeground(QBrush(Qt::red));
                valueItem->setBackground(QBrush(Qt::lightGray));
            }
            else {
                QStandardItem *valueItem = new QStandardItem("-");model->setItem(row, col, valueItem);
                valueItem->setEditable(valueIsEditable);
            }
        }
    }

    emit(refreshView());

}
开发者ID:dm-urievich,项目名称:byce_tool,代码行数:59,代码来源:registersmodel.cpp

示例9: disableMouseOver

void TableView::disableMouseOver()
{
QStandardItemModel _model = static_cast<QStandardItemModel>(model());
for ( int col = 0; col < _model->columnCount(); col++ )
{
QStandardItem *item = _model->item(currHovered, col);

    item->setBackground(QBrush(QColor("white")));
}
}
开发者ID:IMAN4K,项目名称:QtPro,代码行数:10,代码来源:sample.cpp

示例10: DirKnot

DirKnot * HPSKnotDirModel::creatNewActiveKnot(const QString &name,bool hasFiles, const QString &path, const bool isExpanded)
{
    DirKnot *newKnot = new DirKnot();
    newKnot->name = name;
qDebug() << Q_FUNC_INFO << hasFiles;
    QStandardItem *newItem = new QStandardItem(name);
    newItem->setEnabled(true);
    newItem->setToolTip(QDir::toNativeSeparators(path));
    newItem->setData(isExpanded,Qt::UserRole+1);
    newItem->setData(QDir::fromNativeSeparators(path),Qt::UserRole);
    if(hasFiles){
        newKnot->hasFiles = true;
        newItem->setBackground(QBrush(QColor(0,255,0,40)));
    } else {
        newKnot->hasFiles = false;
        newItem->setBackground(QBrush(QColor(0,0,0,0)));
    }
    newKnot->item = newItem;

    return newKnot;
}
开发者ID:abho,项目名称:HPicSync,代码行数:21,代码来源:hpsknotdirmodel.cpp

示例11: QWidget

InterceptWidget::InterceptWidget(IntercepSource * source, QWidget *parent) :
    QWidget(parent),
    source(source)
{
    currentBlockSource = NULL;
    currentGui = NULL;
    ui = new(std::nothrow) Ui::InterceptWidget;
    if (ui == NULL) {
        qFatal("Cannot allocate memory for Ui::InterceptWidget X{");
    }
    ui->setupUi(this);

    packetsTable = new(std::nothrow) QTableView(this);
    if (packetsTable == NULL) {
        qFatal("Cannot allocate memory for QTableView X{");
    }
    QAbstractItemModel *old = packetsTable->model();
    model = source->getModel();
    packetsTable->setModel(model);
    delete old;

    packetsTable->setSelectionMode(QAbstractItemView::ContiguousSelection);
    packetsTable->setSelectionBehavior(QAbstractItemView::SelectRows);
    packetsTable->verticalHeader()->setFont(RegularFont);
    packetsTable->horizontalHeader()->setFont(RegularFont);
    packetsTable->setColumnWidth(PayloadModel::TIMESPTAMP_COLUMN,TIMESTAMP_COLUMN_WIDTH);
    packetsTable->setColumnWidth(PayloadModel::DIRECTION_COLUMN,25);
    packetsTable->verticalHeader()->setDefaultSectionSize(20);
#if QT_VERSION >= 0x050000
    packetsTable->horizontalHeader()->setSectionsMovable( false );
#else
    packetsTable->horizontalHeader()->setMovable(true);
#endif
    connect(packetsTable->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), SLOT(onCurrentSelectedChanged(QModelIndex,QModelIndex)));
    ui->listLayout->addWidget(packetsTable);

    updateColumns();

    sourceChoices << CHOOSE_TEXT << UDP_EXTERNAL_SOURCE_TEXT << TCP_EXTERNAL_SOURCE_TEXT << RAW_TCP_SOURCE_TEXT;
    ui->blockSourceComboBox->addItems(sourceChoices);
    ui->blockSourceComboBox->setCurrentIndex(0);
    QStandardItem * item = qobject_cast<QStandardItemModel *>(ui->blockSourceComboBox->model())->item(0);
    item->setEnabled( false );
    item->setTextAlignment(Qt::AlignCenter);
    item->setBackground(Qt::darkGray);
    item->setForeground(Qt::white);

    connect(ui->blockSourceComboBox, SIGNAL(currentIndexChanged(QString)), SLOT(onSourceChanged(QString)));
}
开发者ID:nccgroup,项目名称:pip3line,代码行数:49,代码来源:interceptwidget.cpp

示例12: enable_persistent

void Peers::enable_persistent(int id)
{
	if (model.rowCount() == 0)
		return;

	QModelIndexList lst = model.match(model.index(0, 0),
					  peer_role_network_id, id);
	for (int i = 0; i < lst.size(); i++) {
		QStandardItem *item = model.itemFromIndex(lst[i]);
		int type = item->data(peer_role_type).toInt();
		if (type == PEER_TYPE_P2P_PERSISTENT_GROUP_GO ||
		    type == PEER_TYPE_P2P_PERSISTENT_GROUP_CLIENT)
			item->setBackground(Qt::NoBrush);
	}
}
开发者ID:MultiNet-80211,项目名称:Hostapd,代码行数:15,代码来源:peers.cpp

示例13: setMouseOver

void TableView::setMouseOver(const int row)
{
if ( row == currHovered) return;

QStandardItemModel *_model = static_cast<QStandardItemModel*>(model());
for ( int col = 0; col < _model->columnCount(); col++ )
{
    QStandardItem *item = _model->item(row, col);

    item->setBackground(QBrush(QColor("red")));
}

if ( currHovered != -1 )
{
    disableMouseOver();
}

currHovered = row;
}
开发者ID:IMAN4K,项目名称:QtPro,代码行数:19,代码来源:sample.cpp

示例14: streamItem

void tst_QStandardItem::streamItem()
{
    QStandardItem item;
    
    item.setText(QLatin1String("text"));
    item.setToolTip(QLatin1String("toolTip"));
    item.setStatusTip(QLatin1String("statusTip"));
    item.setWhatsThis(QLatin1String("whatsThis"));
    item.setSizeHint(QSize(64, 48));
    item.setFont(QFont());
    item.setTextAlignment(Qt::AlignLeft|Qt::AlignVCenter);
    item.setBackground(QColor(Qt::blue));
    item.setForeground(QColor(Qt::green));
    item.setCheckState(Qt::PartiallyChecked);
    item.setAccessibleText(QLatin1String("accessibleText"));
    item.setAccessibleDescription(QLatin1String("accessibleDescription"));

    QByteArray ba;
    {
        QDataStream ds(&ba, QIODevice::WriteOnly);
        ds << item;
    }
    {
        QStandardItem streamedItem;
        QDataStream ds(&ba, QIODevice::ReadOnly);
        ds >> streamedItem;
        QCOMPARE(streamedItem.text(), item.text());
        QCOMPARE(streamedItem.toolTip(), item.toolTip());
        QCOMPARE(streamedItem.statusTip(), item.statusTip());
        QCOMPARE(streamedItem.whatsThis(), item.whatsThis());
        QCOMPARE(streamedItem.sizeHint(), item.sizeHint());
        QCOMPARE(streamedItem.font(), item.font());
        QCOMPARE(streamedItem.textAlignment(), item.textAlignment());
        QCOMPARE(streamedItem.background(), item.background());
        QCOMPARE(streamedItem.foreground(), item.foreground());
        QCOMPARE(streamedItem.checkState(), item.checkState());
        QCOMPARE(streamedItem.accessibleText(), item.accessibleText());
        QCOMPARE(streamedItem.accessibleDescription(), item.accessibleDescription());
        QCOMPARE(streamedItem.flags(), item.flags());
    }
}
开发者ID:maxxant,项目名称:qt,代码行数:41,代码来源:tst_qstandarditem.cpp

示例15: setPresets

void QgsFieldConditionalFormatWidget::setPresets( QList<QgsConditionalStyle> styles )
{
  mPresets.clear();
  mPresetsModel->clear();
  Q_FOREACH ( const QgsConditionalStyle& style, styles )
  {
    if ( style.isValid() )
    {
      QStandardItem* item = new QStandardItem( "abc - 123" );
      if ( style.backgroundColor().isValid() )
        item->setBackground( style.backgroundColor() );
      if ( style.textColor().isValid() )
        item->setForeground( style.textColor() );
      if ( style.symbol() )
        item->setIcon( style.icon() );
      item->setFont( style.font() );
      mPresetsModel->appendRow( item );
      mPresets.append( style );
    }
  }
  mPresetsList->setCurrentIndex( 0 );
}
开发者ID:paulfab,项目名称:QGIS,代码行数:22,代码来源:qgsfieldconditionalformatwidget.cpp


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