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


C++ QTreeWidgetItem::foreground方法代码示例

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


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

示例1: foreground

QBrush QTreeWidgetItemProto::foreground(int column)	        const
{
  QTreeWidgetItem *item = qscriptvalue_cast<QTreeWidgetItem*>(thisObject());
  if (item)
    return item->foreground(column);
  return QBrush();
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例2: on_copyToolButton_clicked

void ColoringRulesDialog::on_copyToolButton_clicked()
{
    if (!ui->coloringRulesTreeWidget->currentItem()) return;
    QTreeWidgetItem *ti = ui->coloringRulesTreeWidget->currentItem();

    addColoringRule(ti->checkState(0) == Qt::Unchecked, ti->text(name_col_),
                    ti->text(filter_col_), ti->foreground(0).color(),
                    ti->background(0).color(), true);
}
开发者ID:crondaemon,项目名称:wireshark,代码行数:9,代码来源:coloring_rules_dialog.cpp

示例3: iter

GSList *ColoringRulesDialog::createColorFilterList()
{
    GSList *cfl = NULL;
    QTreeWidgetItemIterator iter(ui->coloringRulesTreeWidget);

    while (*iter) {
        QTreeWidgetItem *item = (*iter);
        color_t fg = ColorUtils::toColorT(item->foreground(0).color());
        color_t bg = ColorUtils::toColorT(item->background(0).color());
        color_filter_t *colorf = color_filter_new(item->text(name_col_).toUtf8().constData(),
                                                  item->text(filter_col_).toUtf8().constData(),
                                                  &bg, &fg, item->checkState(0) == Qt::Unchecked);
        cfl = g_slist_append(cfl, colorf);
        ++iter;
    }
    return cfl;
}
开发者ID:crondaemon,项目名称:wireshark,代码行数:17,代码来源:coloring_rules_dialog.cpp

示例4: changeColor

void ColoringRulesDialog::changeColor(bool foreground)
{
    if (!ui->coloringRulesTreeWidget->currentItem()) return;

    QTreeWidgetItem *ti = ui->coloringRulesTreeWidget->currentItem();
    QColorDialog color_dlg;

    color_dlg.setCurrentColor(foreground ?
                                  ti->foreground(0).color() : ti->background(0).color());
    if (color_dlg.exec() == QDialog::Accepted) {
        QColor cc = color_dlg.currentColor();
        if (foreground) {
            for (int i = 0; i < ui->coloringRulesTreeWidget->columnCount(); i++) {
                ti->setForeground(i, cc);
            }
        } else {
            for (int i = 0; i < ui->coloringRulesTreeWidget->columnCount(); i++) {
                ti->setBackground(i, cc);
            }
        }
        updateWidgets();
    }

}
开发者ID:crondaemon,项目名称:wireshark,代码行数:24,代码来源:coloring_rules_dialog.cpp

示例5: updateWidgets

void ColoringRulesDialog::updateWidgets()
{
    QString hint = "<small><i>";
    int num_selected = ui->coloringRulesTreeWidget->selectedItems().count();

    if (num_selected == 1) {
        QTreeWidgetItem *ti = ui->coloringRulesTreeWidget->currentItem();
        QString color_button_ss =
                "QPushButton {"
                "  border: 1px solid palette(Dark);"
                "  padding-left: %1px;"
                "  padding-right: %1px;"
                "  color: %2;"
                "  background-color: %3;"
                "}";
        int one_em = fontMetrics().height();
        QString fg_color = ti->foreground(0).color().name();
        QString bg_color = ti->background(0).color().name();
        ui->fGPushButton->setStyleSheet(color_button_ss.arg(one_em).arg(bg_color).arg(fg_color));
        ui->bGPushButton->setStyleSheet(color_button_ss.arg(one_em).arg(fg_color).arg(bg_color));
    }

    ui->copyToolButton->setEnabled(num_selected == 1);
    ui->deleteToolButton->setEnabled(num_selected > 0);
    ui->fGPushButton->setVisible(num_selected == 1);
    ui->bGPushButton->setVisible(num_selected == 1);

    QString error_text;
    QTreeWidgetItemIterator iter(ui->coloringRulesTreeWidget);
    bool enable_save = true;

    while (*iter) {
        QTreeWidgetItem *item = (*iter);
        if (item->text(name_col_).contains("@")) {
            error_text = tr("the \"@\" symbol will be ignored.");
        }

        // Check the rule's display filter syntax only if it's checked.
        QString display_filter = item->text(filter_col_);
        if (!display_filter.isEmpty() && item->checkState(name_col_) == Qt::Checked) {
            dfilter_t *dfilter;
            bool status;
            gchar *err_msg;
            status = dfilter_compile(display_filter.toUtf8().constData(), &dfilter, &err_msg);
            dfilter_free(dfilter);
            if (!status) {
                if (!error_text.isEmpty()) error_text += " ";
                error_text += err_msg;
                g_free(err_msg);
                enable_save = false;
            }
        }

        if (!error_text.isEmpty()) {
            error_text.prepend(QString("%1: ").arg(item->text(name_col_)));
            break;
        }
        ++iter;
    }

    if (error_text.isEmpty()) {
        hint += tr("Double click to edit. Drag to move. Rules are processed in order until a match is found.");
    } else {
        hint += error_text;
    }
    hint += "</i></small>";
    ui->hintLabel->setText(hint);

    ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(enable_save);
}
开发者ID:crondaemon,项目名称:wireshark,代码行数:70,代码来源:coloring_rules_dialog.cpp

示例6: autoLabel

/** Generate labels from the values in the color map.
 *  Skip labels which were manually edited (black text).
 *  Text of generated labels is made gray
 */
void QgsSingleBandPseudoColorRendererWidget::autoLabel()
{
  QgsColorRampShader::ColorRamp_TYPE interpolation = static_cast< QgsColorRampShader::ColorRamp_TYPE >( mColorInterpolationComboBox->itemData( mColorInterpolationComboBox->currentIndex() ).toInt() );
  bool discrete = interpolation == QgsColorRampShader::DISCRETE;
  QString unit = mUnitLineEdit->text();
  QString label;
  int topLevelItemCount = mColormapTreeWidget->topLevelItemCount();
  QTreeWidgetItem* currentItem;
  for ( int i = 0; i < topLevelItemCount; ++i )
  {
    currentItem = mColormapTreeWidget->topLevelItem( i );
    //If the item is null or does not have a pixel values set, skip
    if ( !currentItem || currentItem->text( ValueColumn ).isEmpty() )
    {
      continue;
    }

    if ( discrete )
    {
      if ( i == 0 )
      {
        label = "<= " + currentItem->text( ValueColumn ) + unit;
      }
      else if ( currentItem->text( ValueColumn ).toDouble() == std::numeric_limits<double>::infinity() )
      {
        label = "> " + mColormapTreeWidget->topLevelItem( i - 1 )->text( ValueColumn ) + unit;
      }
      else
      {
        label = mColormapTreeWidget->topLevelItem( i - 1 )->text( ValueColumn ) + " - " + currentItem->text( ValueColumn ) + unit;
      }
    }
    else
    {
      label = currentItem->text( ValueColumn ) + unit;
    }

    if ( currentItem->text( LabelColumn ).isEmpty() || currentItem->text( LabelColumn ) == label || currentItem->foreground( LabelColumn ).color() == QColor( Qt::gray ) )
    {
      currentItem->setText( LabelColumn, label );
      currentItem->setForeground( LabelColumn, QBrush( QColor( Qt::gray ) ) );
    }
  }
}
开发者ID:,项目名称:,代码行数:48,代码来源:


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