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


C++ QStyleOptionButton::init方法代码示例

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


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

示例1: paintEvent

/**
 * Draws the button label.
 */
void ColorButton::paintEvent (QPaintEvent * e)
{
#if 0
    // first paint the complete button
    QPushButton::paintEvent(e);

    // repaint the rectangle area
    QPalette::ColorGroup group = isEnabled() ? hasFocus() ? QPalette::Active : QPalette::Inactive : QPalette::Disabled;
    QColor pen = palette().color(group,QPalette::ButtonText);
    {
        QPainter paint(this);
        paint.setPen(pen);

        if (d->drawFrame) {
            paint.setBrush(QBrush(d->col));
            paint.drawRect(5, 5, width()-10, height()-10);
        }
        else {
            paint.fillRect(5, 5, width()-10, height()-10, QBrush(d->col));
        }
    }

    // overpaint the rectangle to paint icon and text 
    QStyleOptionButton opt;
    opt.init(this);
    opt.text = text();
    opt.icon = icon();
    opt.iconSize = iconSize();

    QStylePainter p(this);
    p.drawControl(QStyle::CE_PushButtonLabel, opt);
#else
    if (d->dirty) {
        QSize isize = iconSize();
        QPixmap pix(isize);
        pix.fill(palette().button().color());

        QPainter p(&pix);

        int w = pix.width();
        int h = pix.height();
        p.setPen(QPen(Qt::gray));
        if (d->drawFrame) {
            p.setBrush(d->col);
            p.drawRect(2, 2, w - 5, h - 5);
        }
        else {
            p.fillRect(0, 0, w, h, QBrush(d->col));
        }
        setIcon(QIcon(pix));

        d->dirty = false;
    }

    QPushButton::paintEvent(e);
#endif
}
开发者ID:AllenBootung,项目名称:FreeCAD,代码行数:60,代码来源:Widgets.cpp

示例2: paintEvent

void InputCheckBox::paintEvent(QPaintEvent * event)
{
  QStyleOptionButton opt;
  opt.init(this);
  QPainter p(this);
  QPalette palette;

  if( isChecked() )
  {
    opt.state |= QStyle::State_On;
  }

  style()->drawControl(QStyle::CE_CheckBox,&opt,&p,this);
}
开发者ID:airguider,项目名称:OpenStudio,代码行数:14,代码来源:EditView.cpp

示例3: setAttribute

void CSVWidget::ColorPickerPopup::mousePressEvent(QMouseEvent *event)
{
    QPushButton *button = qobject_cast<QPushButton *>(parentWidget());
    if (button != NULL)
    {
        QStyleOptionButton option;
        option.init(button);
        QRect buttonRect = option.rect;
        buttonRect.moveTo(button->mapToGlobal(buttonRect.topLeft()));

        // If the mouse is pressed above the pop-up parent,
        // the pop-up will be hidden and the pressed signal won't be repeated for the parent
        if (buttonRect.contains(event->globalPos()) || buttonRect.contains(event->pos()))
        {
            setAttribute(Qt::WA_NoMouseReplay);
        }
    }
    QFrame::mousePressEvent(event);
}
开发者ID:devnexen,项目名称:openmw,代码行数:19,代码来源:colorpickerpopup.cpp

示例4: drawButton

void VColorButton::drawButton(QPainter *p)
{
    QStyleOptionButton buttonOptions;
    buttonOptions.init(this);
    buttonOptions.features = QStyleOptionButton::None;
    buttonOptions.rect = rect();
    buttonOptions.palette = palette();
    buttonOptions.state = (isDown() ? QStyle::State_Sunken : QStyle::State_Raised);
    style()->drawPrimitive(QStyle::PE_PanelButtonBevel, &buttonOptions, p, this);

    p->save();
    drawButtonLabel(p);
    p->restore();

    QStyleOptionFocusRect frectOptions;
    frectOptions.init(this);
    frectOptions.rect = style()->subElementRect(QStyle::SE_PushButtonFocusRect, &buttonOptions, this);
    if (hasFocus())
        style()->drawPrimitive(QStyle::PE_FrameFocusRect, &frectOptions, p, this);
}
开发者ID:curvedspace,项目名称:vibe,代码行数:20,代码来源:vcolorbutton.cpp

示例5: styleOpt

static QStyleOptionButton styleOpt(const QwtArrowButton* btn)
{
    QStyleOptionButton option;
    option.init(btn);
    option.features = QStyleOptionButton::None;
    if (btn->isFlat())
        option.features |= QStyleOptionButton::Flat;
    if (btn->menu())
        option.features |= QStyleOptionButton::HasMenu;
    if (btn->autoDefault() || btn->isDefault())
        option.features |= QStyleOptionButton::AutoDefaultButton;
    if (btn->isDefault())
        option.features |= QStyleOptionButton::DefaultButton;
    if (btn->isDown())
        option.state |= QStyle::State_Sunken;
    if (!btn->isFlat() && !btn->isDown())
        option.state |= QStyle::State_Raised;

    return option;
}
开发者ID:chongle,项目名称:prorata,代码行数:20,代码来源:qwt_arrow_button.cpp

示例6: drawIcon

//-----------------------------------------------------------------------------
QStyleOptionButton ctkPushButtonPrivate::drawIcon(QPainter* p)
{
  Q_Q(ctkPushButton);
  QStyleOptionButton iconOpt;
  iconOpt.init(q);
  iconOpt.rect = this->iconRect();
  QIcon::Mode mode = iconOpt.state & QStyle::State_Enabled ? QIcon::Normal : QIcon::Disabled;
  if (mode == QIcon::Normal && iconOpt.state & QStyle::State_HasFocus)
    {
    mode = QIcon::Active;
    }
  QIcon::State state = QIcon::Off;
  if (iconOpt.state & QStyle::State_On)
    {
    state = QIcon::On;
    }

  QPixmap pixmap = q->icon().pixmap(iconOpt.rect.size(), mode, state);
  p->drawPixmap(iconOpt.rect, pixmap);
  return iconOpt;
}
开发者ID:SarahMang,项目名称:CTK,代码行数:22,代码来源:ctkPushButton.cpp

示例7: paintEvent

void ATCMtime::paintEvent(QPaintEvent * e)
{
    Q_UNUSED( e );
    QPainter painter(this);
    QPalette palette = this->palette();

    QStyleOptionButton opt;
    opt.init(this);

    /* text */
    opt.text = text();

    /* button color */
    palette.setColor(QPalette::Button, m_bgcolor);
    /* font color */
    palette.setColor(QPalette::ButtonText, m_fontcolor);
    /* border color */
    palette.setColor(QPalette::Foreground, m_bordercolor);

    if (m_apparence == QFrame::Raised)
    {
        opt.state = QStyle::State_Off | QStyle::State_Raised;
    }
    else if (m_apparence == QFrame::Sunken)
    {
        opt.state = QStyle::State_Off | QStyle::State_Sunken;
    }
    else
    {
        opt.state = QStyle::State_Off;
    }

    opt.palette = palette;
    _diameter_ = m_borderradius;
    _penWidth_ = m_borderwidth;

    style()->drawControl(QStyle::CE_PushButton, &opt, &painter);
}
开发者ID:MECTsrl,项目名称:mect_plugins,代码行数:38,代码来源:atcmtime.cpp

示例8: editRectangle

QRect LabelTaskMenuInlineEditor::editRectangle() const
{
    QStyleOptionButton opt;
    opt.init(widget());
    return opt.rect;
}
开发者ID:kuailexs,项目名称:symbiandump-mw3,代码行数:6,代码来源:label_taskmenu.cpp

示例9: paintEvent

void ATCMbutton::paintEvent(QPaintEvent * e)
{
    Q_UNUSED( e );
    QPainter painter(this);
    QPalette palette = this->palette();

    QStyleOptionButton opt;
    opt.init(this);

    if (isDown() == false && isChecked() == false)
    {
        /* button color */
        palette.setColor(QPalette::Button, m_bgcolor);
        /* font color */
        palette.setColor(QPalette::ButtonText, m_fontcolor);
        /* border color */
        palette.setColor(QPalette::Foreground, m_bordercolor);
        /* icon */
        opt.icon = m_icon;
        opt.iconSize = iconSize();
        /* text */
        opt.text = m_text;

        if (m_apparence == QFrame::Raised)
        {
            opt.state = QStyle::State_Off | QStyle::State_Raised;
        }
        else if (m_apparence == QFrame::Sunken)
        {
            opt.state = QStyle::State_Off | QStyle::State_Sunken;
        }
        else
        {
            opt.state = QStyle::State_Off;
        }
    }
    else
    {
        /* button color */
        palette.setColor(QPalette::Button, m_bgcolor_press);
        /* font color */
        palette.setColor(QPalette::ButtonText, m_fontcolor_press);
        /* border color */
        palette.setColor(QPalette::Foreground, m_bordercolor_press);
        /* icon */
        opt.icon = m_icon_press;
        opt.iconSize = iconSize();
        /* text */
        opt.text = m_text_press;

        if (m_apparence == QFrame::Raised)
        {
            opt.state = QStyle::State_Off | QStyle::State_Sunken;
        }
        else if (m_apparence == QFrame::Sunken)
        {
            opt.state = QStyle::State_Off | QStyle::State_Raised;
        }
        else
        {
            opt.state = QStyle::State_Off;
        }
    }

#ifdef TARGET_ARM
    if (m_viewstatus) {
        /* draw the background color in funtion of the status */
        palette.setColor(QPalette::Foreground, Qt::red);
        if (m_status & STATUS_OK)
            palette.setColor(QPalette::Foreground, Qt::green);
        else if (m_status & (STATUS_BUSY_R | STATUS_BUSY_W))
            palette.setColor(QPalette::Foreground, Qt::yellow);
        else if (m_status & (STATUS_FAIL_W | STATUS_ERR))
            palette.setColor(QPalette::Foreground, Qt::red);
        else
            palette.setColor(QPalette::Foreground, Qt::gray);
    }
#endif

    opt.palette = palette;
    _diameter_ = m_borderradius;
    _penWidth_ = m_borderwidth;

    style()->drawControl(QStyle::CE_PushButton, &opt, &painter);
}
开发者ID:MECTsrl,项目名称:mect_plugins,代码行数:85,代码来源:atcmbutton.cpp


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