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


C++ QStyle::pixelMetric方法代码示例

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


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

示例1: adjustSliderThumbSize

void RenderThemeQt::adjustSliderThumbSize(RenderObject* o) const
{
    ControlPart part = o->style()->appearance();

    if (part == MediaSliderThumbPart) {
        RenderStyle* parentStyle = o->parent()->style();
        Q_ASSERT(parentStyle);

        int parentHeight = parentStyle->height().value();
        o->style()->setWidth(Length(parentHeight / 3, Fixed));
        o->style()->setHeight(Length(parentHeight, Fixed));
    } else if (part == MediaVolumeSliderThumbPart) {
        RenderStyle* parentStyle = o->parent()->style();
        Q_ASSERT(parentStyle);

        int parentWidth = parentStyle->width().value();
        o->style()->setHeight(Length(parentWidth / 3, Fixed));
        o->style()->setWidth(Length(parentWidth, Fixed));
    } else if (part == SliderThumbHorizontalPart || part == SliderThumbVerticalPart) {
        QStyleOptionSlider option;
        if (part == SliderThumbVerticalPart)
            option.orientation = Qt::Vertical;

        QStyle* style = qStyle();

        int width = style->pixelMetric(QStyle::PM_SliderLength, &option);
        int height = style->pixelMetric(QStyle::PM_SliderThickness, &option);
        o->style()->setWidth(Length(width, Fixed));
        o->style()->setHeight(Length(height, Fixed));
    }
}
开发者ID:sanyaade-mobiledev,项目名称:Webkit-Projects,代码行数:31,代码来源:RenderThemeQt.cpp

示例2: fromFormWindow

void FormWindowData::fromFormWindow(FormWindowBase* fw)
{
    defaultMargin =  defaultSpacing = INT_MIN;
    fw->layoutDefault(&defaultMargin, &defaultSpacing);

    QStyle *style = fw->formContainer()->style();
    layoutDefaultEnabled = defaultMargin != INT_MIN || defaultMargin != INT_MIN;
    if (defaultMargin == INT_MIN)
        defaultMargin = style->pixelMetric(QStyle::PM_DefaultChildMargin, 0);
    if (defaultSpacing == INT_MIN)
        defaultSpacing = style->pixelMetric(QStyle::PM_DefaultLayoutSpacing, 0);


    marginFunction.clear();
    spacingFunction.clear();
    fw->layoutFunction(&marginFunction, &spacingFunction);
    layoutFunctionsEnabled = !marginFunction.isEmpty() || !spacingFunction.isEmpty();

    pixFunction = fw->pixmapFunction();

    author = fw->author();

    includeHints = fw->includeHints();
    includeHints.removeAll(QString());

    hasFormGrid = fw->hasFormGrid();
    grid = hasFormGrid ? fw->designerGrid() : FormWindowBase::defaultDesignerGrid();
}
开发者ID:Fale,项目名称:qtmoko,代码行数:28,代码来源:formwindowsettings.cpp

示例3: QtopiaItemDelegate

QtopiaCLItemDelegate::QtopiaCLItemDelegate(QObject *parent)
    : QtopiaItemDelegate(parent),
    m_min_buddy_height(0), m_vmargin(0), m_hspace(0)
{
  m_tree_view = qobject_cast<QTreeView *>(parent);
  
  if (m_tree_view)
  {
    QStyle *st = m_tree_view->style();
    m_vmargin = st->pixelMetric(QStyle::PM_FocusFrameVMargin);
    m_min_buddy_height = st->pixelMetric(QStyle::PM_ListViewIconSize) + 2*m_vmargin;
    m_hspace = st->pixelMetric(QStyle::PM_LayoutHorizontalSpacing);
  }

  accountFont = QApplication::font();
  accountFont.setPointSize(accountFont.pointSize()+2);
  accountFont.setUnderline(true);
  accountFont.setBold(true);

  groupFont = QApplication::font();
  groupFont.setPointSize(groupFont.pointSize()+2);

  separatorFont = QApplication::font();
  separatorFont.setItalic(true);


  firstLineFont = QApplication::font();
  firstLineFont.setPointSize(firstLineFont.pointSize()+1);

  secondLineFont = QApplication::font();
  secondLineFont.setPointSize(secondLineFont.pointSize()-1);
}
开发者ID:RankoR,项目名称:mqutim,代码行数:32,代码来源:contactlistitemdelegate_qtopia.cpp

示例4: QSize

/*!
  \brief Gets the suitable size of project window.
  This size is just suitable for the whole project area with 1px border and
  the scroll bar.
  \return suitable size of this project window
 */
QSize Ui::ProjectWindow::sizeHint() const
{
    QStyle *style = qApp->style();
    int frameBorderWidth = style->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth);
    int frameTitleHeight = style->pixelMetric(QStyle::PM_TitleBarHeight);
    int scrollBarWidth = style->pixelMetric(QStyle::PM_ScrollBarExtent);
    return QSize(view->width() + (frameBorderWidth << 1) + scrollBarWidth + 2,
                 view->height() + frameTitleHeight + frameBorderWidth + statusBar->height() - 10);
}
开发者ID:jaisurya,项目名称:picworks,代码行数:15,代码来源:projectwindow.cpp

示例5: updateMarginAndSpacing

void QToolBarLayout::updateMarginAndSpacing()
{
    QToolBar *tb = qobject_cast<QToolBar*>(parentWidget());
    if (!tb)
        return;
    QStyle *style = tb->style();
    QStyleOptionToolBar opt;
    tb->initStyleOption(&opt);
    setMargin(style->pixelMetric(QStyle::PM_ToolBarItemMargin, &opt, tb)
                + style->pixelMetric(QStyle::PM_ToolBarFrameWidth, &opt, tb));
    setSpacing(style->pixelMetric(QStyle::PM_ToolBarItemSpacing, &opt, tb));
}
开发者ID:wpbest,项目名称:copperspice,代码行数:12,代码来源:qtoolbarlayout.cpp

示例6: updateMarginAndSpacing

void StatusBarLayout::updateMarginAndSpacing()
{
    Statusbar* statusBar = qobject_cast<Statusbar*>( parentWidget() );
    if( ! statusBar )
        return;

    QStyle* style = statusBar->style();
    QStyleOptionToolBar opt;
    statusBar->initStyleOption( &opt );
    setMargin( style->pixelMetric(QStyle::PM_ToolBarItemMargin, &opt, statusBar)
                + style->pixelMetric(QStyle::PM_ToolBarFrameWidth, &opt, statusBar) );
    setSpacing( style->pixelMetric(QStyle::PM_ToolBarItemSpacing, &opt, statusBar) );
}
开发者ID:ShermanHuang,项目名称:kdesdk,代码行数:13,代码来源:statusbarlayout.cpp

示例7: paint

/**
 * @todo enable eliding (use QFontMetrics::elidedText() )
 */
void bicItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
  QStyleOptionViewItem opt = option;
  initStyleOption(&opt, index);

  // Background
  QStyle *style = opt.widget ? opt.widget->style() : QApplication::style();
  style->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, opt.widget);

  const int margin = style->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;
  const QRect textArea = QRect(opt.rect.x() + margin, opt.rect.y() + margin, opt.rect.width() - 2 * margin, opt.rect.height() - 2 * margin);

  // Paint name
  painter->save();
  QFont smallFont = getSmallFont(opt);
  QFontMetrics metrics(opt.font);
  QFontMetrics smallMetrics(smallFont);
  QRect nameRect = style->alignedRect(opt.direction, Qt::AlignBottom, QSize(textArea.width(), smallMetrics.lineSpacing()), textArea);
  painter->setFont(smallFont);
  style->drawItemText(painter, nameRect, Qt::AlignBottom, QApplication::palette(), true, index.model()->data(index, bicModel::InstitutionNameRole).toString(), option.state & QStyle::State_Selected ? QPalette::HighlightedText : QPalette::Mid);
  painter->restore();

  // Paint BIC
  painter->save();
  QFont normal = painter->font();
  normal.setBold(true);
  painter->setFont(normal);
  QRect bicRect = style->alignedRect(opt.direction, Qt::AlignTop, QSize(textArea.width(), metrics.lineSpacing()), textArea);
  const QString bic = index.model()->data(index, Qt::DisplayRole).toString();
  style->drawItemText(painter, bicRect, Qt::AlignTop, QApplication::palette(), true, bic, option.state & QStyle::State_Selected ? QPalette::HighlightedText : QPalette::Text);

  painter->restore();
}
开发者ID:KDE,项目名称:kmymoney,代码行数:36,代码来源:kbicedit.cpp

示例8: init

void QToolBarPrivate::init()
{
    Q_Q(QToolBar);
    q->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed));
    q->setBackgroundRole(QPalette::Button);
    q->setAttribute(Qt::WA_Hover);
    q->setAttribute(Qt::WA_X11NetWmWindowTypeToolBar);

    QStyle *style = q->style();
    int e = style->pixelMetric(QStyle::PM_ToolBarIconSize, 0, q);
    iconSize = QSize(e, e);

    layout = new QToolBarLayout(q);
    layout->updateMarginAndSpacing();

#ifdef Q_WS_MAC
    if (q->parentWidget() && q->parentWidget()->isWindow()) {
        // Make sure that the window has the "toolbar" button.
        QWidget *parentWidget = q->parentWidget();
        qt_mac_updateToolBarButtonHint(parentWidget);
        reinterpret_cast<QToolBar *>(parentWidget)->d_func()->createWinId(); // Please let me create your winId...
        extern OSWindowRef qt_mac_window_for(const QWidget *); // qwidget_mac.cpp
        macWindowToolbarShow(q->parentWidget(), true);
    }
#endif

    toggleViewAction = new QAction(q);
    toggleViewAction->setCheckable(true);
    q->setMovable(q->style()->styleHint(QStyle::SH_ToolBar_Movable, 0, q ));
    QObject::connect(toggleViewAction, SIGNAL(triggered(bool)), q, SLOT(_q_toggleView(bool)));
}
开发者ID:dirlinch,项目名称:chromecast-mirrored-source.vendor,代码行数:31,代码来源:qtoolbar.cpp

示例9: paint

void PhotoDelegate::paint(
        QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    QPen oldPen = painter->pen();

    QStyle *style = QApplication::style();

    int margin = style->pixelMetric(QStyle::PM_ButtonMargin);

    QRect rect = option.rect;

    if (option.state & QStyle::State_HasFocus) {
        painter->fillRect(rect, option.palette.highlight());

        painter->setPen(option.palette.color(QPalette::HighlightedText));
    }

    rect.adjust(margin, margin, -margin, -margin);

    QRect decorationRect = rect;
    decorationRect.setRight(decorationRect.left() + option.decorationSize.width());

    QPixmap decoration = qvariant_cast<QPixmap>(index.data(Qt::DecorationRole));
    if (!decoration.isNull())
        style->drawItemPixmap(painter, decorationRect, Qt::AlignCenter, decoration);
    else
        painter->drawRect(decorationRect);

    painter->setPen(oldPen);
}
开发者ID:kaltsi,项目名称:qt-mobility,代码行数:30,代码来源:photodelegate.cpp

示例10: sizeHint

QSize SearchItemDelegate::sizeHint(const QStyleOptionViewItem &option,
                                   const QModelIndex &index) const
{
    QStyleOptionViewItem opt(option);

    QStyle *style = opt.widget->style();

    QSize size = QStyledItemDelegate::sizeHint(opt, index);
    size.setWidth(0);

    const int margin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, &opt, opt.widget) + 1;

    // Find decoration roles with data present.
    QList<int> roles;
    for (int role : m_decorationRoles) {
        if (!index.data(role).isNull())
            roles.append(role);
    }

    if (!roles.isEmpty()) {
        const QIcon icon = index.data(roles.first()).value<QIcon>();
        const QSize actualSize = icon.actualSize(opt.decorationSize);
        const int decorationWidth = std::min(opt.decorationSize.width(), actualSize.width());
        size.rwidth() = (decorationWidth + margin) * roles.size() + margin;
    }

    size.rwidth() += opt.fontMetrics.width(index.data().toString()) + margin * 2;
    return size;
}
开发者ID:leo8916,项目名称:zeal,代码行数:29,代码来源:searchitemdelegate.cpp

示例11: QDialog

//-----------------------------------------------------------------------------
qtConfirmationDialog::qtConfirmationDialog(
  const QString& askKey, QWidget* parent, Qt::WindowFlags flags)
  : QDialog(parent, flags), d_ptr(new qtConfirmationDialogPrivate)
{
  QTE_D(qtConfirmationDialog);

  d->AskKey = askKey;

  // Create UI
  d->UI.setupUi(this);
  this->setConfirmText("Continue");
  qtUtil::setStandardIcons(d->UI.buttonBox);

  // Set dialog icon
  QStyle* style = this->style();
  int iconSize = style->pixelMetric(QStyle::PM_MessageBoxIconSize, 0, this);
  QIcon icon = style->standardIcon(QStyle::SP_MessageBoxWarning, 0, this);
  QPixmap pixmap = icon.pixmap(iconSize, iconSize);
  d->UI.image->setPixmap(pixmap);
  d->UI.image->setFixedSize(pixmap.size());

  // Hide unneeded "don't ask" controls
  d->UI.noAsk->setHidden(askKey.isEmpty());
  d->UI.noAskSession->hide();
  d->UI.noAskEver->hide();
}
开发者ID:Kitware,项目名称:qtextensions,代码行数:27,代码来源:qtConfirmationDialog.cpp

示例12:

NS_IMETHODIMP
nsNativeThemeQt::ThemeChanged()
{
    QStyle *s = qApp->style();
    if (s)
        mFrameWidth = s->pixelMetric(QStyle::PM_DefaultFrameWidth);
    return NS_OK;
}
开发者ID:,项目名称:,代码行数:8,代码来源:

示例13: paint

/** @todo elide texts */
void ibanBicItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
    QStyleOptionViewItem opt = option;
    initStyleOption(&opt, index);

    // Background
    QStyle *style = opt.widget ? opt.widget->style() : QApplication::style();
    style->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, opt.widget);

    const int margin = style->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;
    const QRect textArea = QRect(opt.rect.x() + margin, opt.rect.y() + margin, opt.rect.width() - 2 * margin, opt.rect.height() - 2 * margin);

    // Do not paint text if the edit widget is shown
    const QAbstractItemView *view = qobject_cast<const QAbstractItemView *>(opt.widget);
    if (view && view->indexWidget(index))
        return;

    // Get data
    payeeIdentifierTyped<payeeIdentifiers::ibanBic> ibanBic = ibanBicByIndex(index);

    // Paint Bic
    painter->save();
    const QFont smallFont = painter->font();
    const QFontMetrics metrics(opt.font);
    const QFontMetrics smallMetrics(smallFont);
    const QRect bicRect = style->alignedRect((opt.direction  == Qt::RightToLeft) ? Qt::LeftToRight : Qt::RightToLeft, Qt::AlignTop, QSize(textArea.width(), smallMetrics.lineSpacing()),
                          QRect(textArea.left(), metrics.lineSpacing() + textArea.top(), textArea.width(), smallMetrics.lineSpacing())
                                            );
    painter->setFont(smallFont);
    style->drawItemText(painter, bicRect, Qt::AlignBottom | Qt::AlignRight, QApplication::palette(), true, ibanBic->storedBic(), opt.state & QStyle::State_Selected ? QPalette::HighlightedText : QPalette::Text);
    painter->restore();

    // Paint Bank name
    painter->save();
    const QRect nameRect = style->alignedRect(opt.direction, Qt::AlignTop, QSize(textArea.width(), smallMetrics.lineSpacing()),
                           QRect(textArea.left(), metrics.lineSpacing() + textArea.top(), textArea.width(), smallMetrics.lineSpacing())
                                             );
    style->drawItemText(painter, nameRect, Qt::AlignBottom, QApplication::palette(), true, ibanBic->institutionName(), opt.state & QStyle::State_Selected ? QPalette::HighlightedText : QPalette::Text);
    painter->restore();

    // Paint IBAN
    painter->save();
    QFont normal = painter->font();
    normal.setBold(true);
    painter->setFont(normal);
    const QRect ibanRect = style->alignedRect(opt.direction, Qt::AlignTop, QSize(textArea.width(), metrics.lineSpacing()), textArea);
    const QString bic = index.model()->data(index, Qt::DisplayRole).toString();
    style->drawItemText(painter, ibanRect, Qt::AlignTop, QApplication::palette(), true, ibanBic->paperformatIban(), opt.state & QStyle::State_Selected ? QPalette::HighlightedText : QPalette::Text);
    painter->restore();

    // Paint type
    painter->save();
    QRect typeRect = style->alignedRect(opt.direction, Qt::AlignTop | Qt::AlignRight, QSize(textArea.width() / 5, metrics.lineSpacing()), textArea);
    style->drawItemText(painter, typeRect, Qt::AlignTop | Qt::AlignRight, QApplication::palette(), true, i18n("IBAN & BIC"), opt.state & QStyle::State_Selected ? QPalette::HighlightedText : QPalette::Text);
    painter->restore();
}
开发者ID:KDE,项目名称:kmymoney,代码行数:57,代码来源:ibanbicitemdelegate.cpp

示例14: horizontalScrollbarHeight

int PlatformScrollbar::horizontalScrollbarHeight(ScrollbarControlSize controlSize)
{
    QStyle *s = QApplication::style();
    QStyleOptionSlider o;
    o.orientation = Qt::Horizontal;
    o.state |= QStyle::State_Horizontal;
    if (controlSize != RegularScrollbar)
        o.state |= QStyle::State_Mini;
    return s->pixelMetric(QStyle::PM_ScrollBarExtent, &o, 0);
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:10,代码来源:PlatformScrollBarQt.cpp

示例15: scrollbarThickness

int ScrollbarThemeQt::scrollbarThickness(ScrollbarControlSize controlSize)
{
    QStyle* s = QApplication::style();
    QStyleOptionSlider o;
    o.orientation = Qt::Vertical;
    o.state &= ~QStyle::State_Horizontal;
    if (controlSize != RegularScrollbar)
        o.state |= QStyle::State_Mini;
    return s->pixelMetric(QStyle::PM_ScrollBarExtent, &o, 0);
}
开发者ID:,项目名称:,代码行数:10,代码来源:


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