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


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

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


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

示例1: foreground

ServiceMessagesPage::ServiceMessagesPage(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ServiceMessagesPage),
    clientModel(0),
    walletModel(0)
{
    ui->setupUi(this);

    connect(ui->tableServiceMessagesView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(handleClicked(QModelIndex)));

    QColor foreground(qRgb(48,134,196));
    QStandardItemModel* model = new QStandardItemModel(2, 2, this);

    for (int i = 0; i < 0; ++i)
    {
        QStandardItem* item = new QStandardItem(trUtf8("17:56, 01.03.2012"));
        item->setForeground(foreground);
        model->setItem(i, 0, item);

        item = new QStandardItem(QString::fromUtf8(
                                     i == 0 ?
                                         "":
                                         ""));
        item->setForeground(foreground);
        model->setItem(i, 1, item);
    }

    ui->tableServiceMessagesView->setModel(model);
    ui->tableServiceMessagesView->setColumnWidth(0, 120);
    ui->tableServiceMessagesView->horizontalHeader()->setStretchLastSection(true);
    ui->tableServiceMessagesView->resizeRowsToContents();
}
开发者ID:CarbonTradingcoin,项目名称:CarbonTradingcoin,代码行数:32,代码来源:servicemessagespage.cpp

示例2: addIncident

// -------- QTestFunction
void QTestFunction::addIncident(IncidentType type,
                                const QString &file,
                                const QString &line,
                                const QString &details)
{
    QStandardItem *status = new QStandardItem(incidentString(type));
    status->setData(QVariant::fromValue(type));

    switch (type) {
        case QTestFunction::Pass: status->setForeground(Qt::green); break;
        case QTestFunction::Fail: status->setForeground(Qt::red); break;
        case QTestFunction::XFail: status->setForeground(Qt::darkMagenta); break;
        case QTestFunction::XPass: status->setForeground(Qt::darkGreen); break;
    }

    QStandardItem *location = new QStandardItem;
    if (!file.isEmpty()) {
        location->setText(file + QLatin1Char(':') + line);
        location->setForeground(Qt::red);

        QTestLocation loc;
        loc.file = file;
        loc.line = line;
        location->setData(QVariant::fromValue(loc));
    }

    appendRow(QList<QStandardItem *>() << status << location);

    if (!details.isEmpty()) {
        status->setColumnCount(2);
        status->appendRow(QList<QStandardItem *>() << new QStandardItem() << new QStandardItem(details));
    }
}
开发者ID:anchowee,项目名称:QtCreator,代码行数:34,代码来源:qtestlibplugin.cpp

示例3: addOneRecordToModel

static void addOneRecordToModel(const data::AccountReceivableRecord & record
                                , QStandardItemModel * model
                                , bool isChecked)
{
    QList<QStandardItem *> row;
    row.append(new QStandardItem);
    row.append(new QStandardItem(record.date.toString("yyyy-MM-dd")));
    row.append(new QStandardItem(record.product.category.name));
    row.append(new QStandardItem(record.product.name));
    row.append(new QStandardItem(QString("%1").arg(record.quantity)));

    if (0 == record.price) {
        QBrush redBrush(Qt::red);

        QStandardItem * item = new QStandardItem(QObject::tr("Please assign unzero price"));
        item->setForeground(redBrush);

        row.append(item);
    } else {
        row.append(new QStandardItem(QString("%1").arg(record.quantity * record.price)));
    }

    row.first()->setCheckable(true);
    row.first()->setCheckState(isChecked ? Qt::Checked : Qt::Unchecked);

    for (int i = 0; i < row.size(); ++i)
        row[i]->setEditable(false);

    model->appendRow(row);
}
开发者ID:YSYou,项目名称:LADS2,代码行数:30,代码来源:StrikeBalanceWidget.cpp

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

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

示例6: QStandardItem

QList<QStandardItem*> QDatabaseTableViewController::makeStandardItemListFromStringList(const QList<QString>& szStringList)
{
	QList<QStandardItem*> listStandardItemList;
	QStandardItem* pStandardItem;
	QFont font;

	QPalette palette = QApplication::palette(m_pDatabaseTableView);
	QBrush nullbrush = palette.brush(QPalette::Disabled, QPalette::Text);

	QList<QString>::const_iterator iter = szStringList.begin();
	while(iter != szStringList.end())
	{
		//Getting an item from QList<QString> to add it to a QList<QStandardItem>
		if((*iter).isNull()){
			pStandardItem = new QStandardItem(QString("NULL"));
			font = pStandardItem->font();
			font.setItalic(true);
			pStandardItem->setFont(font);
			pStandardItem->setForeground(nullbrush);
		} else {
			pStandardItem = new QStandardItem(*iter);
		}
		pStandardItem->setEditable(true);
		listStandardItemList.append(pStandardItem);
		iter++;
	}
	return listStandardItemList;
}
开发者ID:Jet1oeil,项目名称:opendbviewer,代码行数:28,代码来源:QDatabaseTableViewController.cpp

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

示例8: updatePartSelection

void TrackListView::updatePartSelection(Part* part)/*{{{*/
{
    if(part)
    {
        MidiTrack* track = part->track();
        Part* curPart = m_editor->curCanvasPart();
        if (curPart)
        {
            song->setRecordFlag(curPart->track(), false);
        }
        m_editor->setCurCanvasPart(part);
        Song::movePlaybackToPart(part);
        // and turn it on for the new parts track
        song->setRecordFlag(track, true);
        song->deselectTracks();
        song->deselectAllParts();
        track->setSelected(true);
        part->setSelected(true);
        song->update(SC_SELECTION);

        int psn = part->sn();
        for(int i = 0; i < m_model->rowCount(); ++i)
        {
            QStandardItem* item = m_model->item(i, 0);
            if(item)
            {
                int type = item->data(TrackRole).toInt();
                if(type == 1)
                {//TrackMode
                    continue;
                }
                else
                {//PartMode
                    int sn = item->data(PartRole).toInt();
                    if(psn == sn)
                    {
                        m_selectedIndex = item->row();

                        m_tempColor = item->foreground();

                        m_model->blockSignals(true);
                        item->setForeground(QColor(99, 36, 36));
                        m_model->blockSignals(false);
                        update();
                        m_table->selectRow(m_selectedIndex);
                        m_table->scrollTo(m_model->index(m_selectedIndex, 0));

                        m_colorRows.append(m_selectedIndex);

                        QTimer::singleShot(350, this, SLOT(updateColor()));
                        break;
                    }
                }
            }
        }
    }
}/*}}}*/
开发者ID:peter1000,项目名称:los,代码行数:57,代码来源:tracklistview.cpp

示例9: rn

//*** class PathEnum ***
PathEnum::PathEnum(const CppReader &reader, CppObjList &objs):
    ok(false), reader(reader)
{
    //recognization?
    if( !reader.header().startsWith("enum"))
        return;
    ok = true;
    //yes!

    //whether exists the enum name?
    QString name;
    QRegExp rn("^enum\\s+([a-zA-Z_]\\w*)\\s*$");
    if(reader.header().contains(rn) &&
            ! objs.indexOf( name = rn.cap(1)) )        //query for the existance of the name.
    {
        QStandardItem *item = new Item::CppItem(Item::Enum);
        item->setForeground(Qt::darkMagenta);
        item->setData(rn.cap(1),Item::NameRole);
        item->setData(reader.header(),Qt::ToolTipRole);
        item->setEditable(false);
        objs.append( item);
    }

    //the content of the enum.
    QStringList list = reader.body().split(',',QString::SkipEmptyParts);
    QRegExp rx("^\\s*([a-zA-Z_]\\w*)\\s*(?:=[^,;]+)?$");
    foreach (const QString &it, list)
    {
        if(! it.contains(rx) )
            continue;
        if( ! objs.indexOf( rx.cap(1)))
        {
            QStandardItem *item = new Item::CppItem(Item::Enumerator);
            item->setForeground(Qt::darkMagenta);
            item->setData(rx.cap(1),Item::NameRole);
            item->setData("enum: " + it,Qt::ToolTipRole);
            item->setData( name.isEmpty() ? "int" : name, Item::PurifiedTypeRole);
            item->setEditable(false);
            objs.append( item);
        }
    }
}
开发者ID:sefloware,项目名称:GBR,代码行数:43,代码来源:cppenumespace.cpp

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

示例11: fillItemModel_availableComponents

void RxDev::fillItemModel_availableComponents(const QString compFile)
{
    int begin = compFile.lastIndexOf("/")+1;
    int end = compFile.lastIndexOf(".launch");
    QString subString = compFile.mid(begin,end-begin);

    QStandardItem *group = new QStandardItem(QString("%1").arg(subString));
    QStandardItem *path = new QStandardItem(QString("%1").arg(compFile));
    QBrush b;
    b.setColor(Qt::darkBlue);
    group->setForeground(b);
    group->appendRow(path);

    // append group as new row to the model. model takes the ownership of the item
            model_availableComponents->appendRow(group);
}
开发者ID:6opb6a,项目名称:rxdeveloper-ros-pkg,代码行数:16,代码来源:c_connector.cpp

示例12: updateColor

void TrackListView::updateColor()
{
    while(!m_colorRows.isEmpty())
    {
        int row = m_colorRows.takeFirst();
        QStandardItem *item = m_model->item(row);
        if(item)
        {
            //qDebug("TrackListView::updateColor: row: %d", row);
            m_model->blockSignals(true);
            item->setForeground(QColor(187, 191, 187));
            m_model->blockSignals(false);
        }
    }
    update();
}
开发者ID:peter1000,项目名称:los,代码行数:16,代码来源:tracklistview.cpp

示例13: log

/*!
    Log a message.

    If the module should determinated automaticly use the function
    log(const Level level, const QString &message, const QObject *sender) instead.

    \param level One of the message level identifiers, e.g., Warning
    \param message The message
    \param module The calling module
*/
void QLoggerModel::log(const Level level, const QString &message, const QString &module)
{
    if (message.isEmpty())
        return;

    const quint32 iLevel = static_cast<quint32>(level);
    const QBrush textColor(FOREGROUNDCOLORS[iLevel]);

    const QString strTime = QTime::currentTime().toString(*QLOGGERVIEW_STR_TIMEFORMAT);
    const QString strModule = module.isEmpty() ? tr(*QLOGGERVIEW_STR_UNKNOWN) : module;
    const QString strMsg = QString("%0 [%1] %2").arg(strTime).arg(strModule).arg(message);

    QStandardItem *item = new QStandardItem(_iconList.at(iLevel), strMsg);
    item->setForeground(textColor);

    appendRow(item);
}
开发者ID:philivanilli,项目名称:PartzDB,代码行数:27,代码来源:qloggermodel.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: select

void CodeEditor::select(QStandardItem *parent,const QStandardItem *sourceParent)
{
    for (int i=0; i<sourceParent->rowCount(); ++i)
    {
       QStandardItem *child = sourceParent->child(i);

       QStandardItem *item = child->QStandardItem::clone();
       item->setToolTip(child->toolTip());
       assert(item);

       QString text = child->data(Item::DescriptionRole).toStringList().join('\n');
       QStandardItem *desitem = new QStandardItem(text);
       desitem->setForeground(Qt::darkGreen);
       desitem->setEditable(false);

       parent->appendRow(QList<QStandardItem *>() << item << desitem);

       if(child->hasChildren())
           select(item,child);
    }
}
开发者ID:sefloware,项目名称:GBR,代码行数:21,代码来源:stcodeeditor.cpp


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