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


C++ QStyleOption::initFrom方法代码示例

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


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

示例1: paintEvent

/* Necesario para poner estilos a traves de hojas CSS.
*/
void BlWidget::paintEvent ( QPaintEvent * )
{
    QStyleOption option;
    option.initFrom ( this );
    QPainter painter ( this );
    style()->drawPrimitive ( QStyle::PE_Widget, &option, &painter, this );
}
开发者ID:trifolio6,项目名称:Bulmages,代码行数:9,代码来源:blwidget.cpp

示例2: paintEvent

void WDisplay::paintEvent(QPaintEvent* ) {
    QStyleOption option;
    option.initFrom(this);
    QStylePainter p(this);
    p.drawPrimitive(QStyle::PE_Widget, option);

    if (m_pPixmapBack) {
        m_pPixmapBack->draw(0, 0, &p);
    }

    // If we are disabled, use the disabled pixmaps. If not, use the regular
    // pixmaps.
    const QVector<PaintablePointer>& pixmaps = (isDisabled() && m_bDisabledLoaded) ?
            m_disabledPixmaps : m_pixmaps;

    if (pixmaps.empty()) {
        return;
    }

    int idx = getActivePixmapIndex();

    // Clamp active pixmap index to valid ranges.
    if (idx < 0) {
        idx = 0;
    } else if (idx >= pixmaps.size()) {
        idx = pixmaps.size() - 1;
    }

    PaintablePointer pPixmap = pixmaps[idx];
    if (pPixmap) {
        pPixmap->draw(0, 0, &p);
    }
}
开发者ID:suyoghc,项目名称:mixxx,代码行数:33,代码来源:wdisplay.cpp

示例3: paintEvent

/// This method is required when Q_OBJECT is added
/// Without this method, the CSS will not be applied
void MapWidget::paintEvent(QPaintEvent *pe) {
    QStyleOption o;
    o.initFrom(this);
    QPainter p(this);
    style()->drawPrimitive(
        QStyle::PE_Widget, &o, &p, this);
};
开发者ID:amirbawab,项目名称:PowerGrid,代码行数:9,代码来源:MapWidget.cpp

示例4: paintEvent

void WKnobComposed::paintEvent(QPaintEvent* e) {
    Q_UNUSED(e);
    QStyleOption option;
    option.initFrom(this);
    QStylePainter p(this);
    p.setRenderHint(QPainter::Antialiasing);
    p.setRenderHint(QPainter::SmoothPixmapTransform);
    p.drawPrimitive(QStyle::PE_Widget, option);

    if (m_pPixmapBack) {
        m_pPixmapBack->draw(0, 0, &p);
    }

    if (!m_pKnob.isNull() && !m_pKnob->isNull()) {
        p.translate(width() / 2.0, height() / 2.0);

        // Value is in the range [0, 1].
        double value = getValue();

        double angle = m_dMinAngle + (m_dMaxAngle - m_dMinAngle) * value;
        p.rotate(angle);

        m_pKnob->draw(-m_pKnob->width() / 2.0, -m_pKnob->height() / 2.0, &p);
    }
}
开发者ID:suyoghc,项目名称:mixxx,代码行数:25,代码来源:wknobcomposed.cpp

示例5: LineEditInterface

ExtendedEditor::ExtendedEditor(QWidget* widget, int extra_right_padding,
                               bool draw_hint)
    : LineEditInterface(widget),
      has_clear_button_(true),
      clear_button_(new QToolButton(widget)),
      reset_button_(new QToolButton(widget)),
      extra_right_padding_(extra_right_padding),
      draw_hint_(draw_hint),
      font_point_size_(widget->font().pointSizeF() - 1),
      is_rtl_(false) {
  clear_button_->setIcon(IconLoader::Load("edit-clear-locationbar-ltr", IconLoader::Base));
  clear_button_->setIconSize(QSize(16, 16));
  clear_button_->setCursor(Qt::ArrowCursor);
  clear_button_->setStyleSheet("QToolButton { border: none; padding: 0px; }");
  clear_button_->setToolTip(widget->tr("Clear"));
  clear_button_->setFocusPolicy(Qt::NoFocus);

  QStyleOption opt;
  opt.initFrom(widget);

  reset_button_->setIcon(widget->style()->standardIcon(
      QStyle::SP_DialogResetButton, &opt, widget));
  reset_button_->setIconSize(QSize(16, 16));
  reset_button_->setCursor(Qt::ArrowCursor);
  reset_button_->setStyleSheet("QToolButton { border: none; padding: 0px; }");
  reset_button_->setToolTip(widget->tr("Reset"));
  reset_button_->setFocusPolicy(Qt::NoFocus);
  reset_button_->hide();

  widget->connect(clear_button_, SIGNAL(clicked()), widget, SLOT(clear()));
  widget->connect(clear_button_, SIGNAL(clicked()), widget, SLOT(setFocus()));

  UpdateButtonGeometry();
}
开发者ID:Atrament666,项目名称:Clementine,代码行数:34,代码来源:lineedit.cpp

示例6: paintEvent

void DisplayArea::paintEvent(ATTR_UNUSED QPaintEvent *event)
{
    QStyleOption o;
    o.initFrom(this);
    QPainter p(this);
    style()->drawPrimitive(QStyle::PE_Widget, &o, &p, this);
}
开发者ID:crapp,项目名称:labpowerqt,代码行数:7,代码来源:displayarea.cpp

示例7: paintEvent

void DevMode::paintEvent(QPaintEvent*)
{
    using pv::view::Trace;

    QStyleOption o;
    o.initFrom(this);
    QPainter painter(this);
    style()->drawPrimitive(QStyle::PE_Widget, &o, &painter, this);

    painter.setRenderHint(QPainter::Antialiasing);
    painter.setPen(Qt::NoPen);
    for(std::map<boost::shared_ptr<QPushButton>, sr_dev_mode *>::const_iterator i = _mode_button_list.begin();
        i != _mode_button_list.end(); i++) {
        const boost::shared_ptr<device::DevInst> dev_inst = _view.session().get_device();
        assert(dev_inst);
        if (dev_inst->dev_inst()->mode == (*i).second->mode)
            painter.setBrush(Trace::dsBlue);
        else
            painter.setBrush(Trace::dsGray);

        painter.drawRoundedRect((*i).first->geometry(), 4, 4);
    }

    painter.end();
}
开发者ID:MatteoMilandri,项目名称:DSView,代码行数:25,代码来源:devmode.cpp

示例8: ps

void
CQSplitterHandle::
paintEvent(QPaintEvent *)
{
  QStylePainter ps(this);

  QStyleOption opt;

#if 0
  ps.fillRect(rect(), QBrush(QColor(100,100,150)));
#else
  opt.initFrom(this);

  opt.rect  = rect();
  opt.state = (! area_->isVerticalDockArea() ? QStyle::State_None : QStyle::State_Horizontal);

  if (mouseState_.pressed)
    opt.state |= QStyle::State_Sunken;

  if (mouseOver_)
    opt.state |= QStyle::State_MouseOver;

  ps.drawControl(QStyle::CE_Splitter, opt);
#endif
}
开发者ID:colinw7,项目名称:CQPaletteArea,代码行数:25,代码来源:CQSplitterArea.cpp

示例9: sizeHint

QSize KLed::sizeHint() const
{
    QStyleOption option;
    option.initFrom(this);
    int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize, &option, this);
    return QSize( iconSize,  iconSize );
}
开发者ID:ViktorNova,项目名称:chipsynth,代码行数:7,代码来源:kled.cpp

示例10: QwwButtonLineEdit

/*!
 * Constructs a file chooser with a given \a parent.
 * 
 */
QwwFileChooser::QwwFileChooser(QWidget *parent) : QwwButtonLineEdit(*new QwwFileChooserPrivate(this), parent) {
    Q_D(QwwFileChooser);
#if QT_VERSION >= 0x040200 && !defined(QT_NO_COMPLETER)
    d->completer = new QCompleter(this);
    setCompleter(d->completer);
    QStyleOption opt;
    opt.initFrom(this);
    int mar = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, &opt, this);
    int siz = style()->pixelMetric(QStyle::PM_SmallIconSize, &opt, this);
#if QT_VERSION >=0x040500
    setTextMargins(siz+2, 0, 0, 0);
#else
    setStyleSheet(QString("QwwFileChooser {padding-left: %1px;}").arg(mar+siz+2));
#endif

//     connect(this, SIGNAL(textEdited(const QString&)), d->completer, SLOT(setCompletionPrefix(const QString&)));
#endif
    setModel(new QDirModel(this));
    setButtonPosition(RightOutside);
    connect(this, SIGNAL(buttonClicked()), this, SLOT(chooseFile()));
    setAutoRaise(true);
    setAcceptMode(QFileDialog::AcceptOpen);

    QShortcut *sc = new QShortcut(QKeySequence("Ctrl+Space"), this);
    connect(sc, SIGNAL(activated()), d->completer, SLOT(complete()));
    connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(_q_textChanged(const QString&)));
}
开发者ID:TheDZhon,项目名称:wwwidgets,代码行数:31,代码来源:qwwfilechooser.cpp

示例11: paintEvent

    virtual void paintEvent( QPaintEvent* ) {
        QPainter p( this );
        QStyleOption opt;
        opt.initFrom( this );
        QRect r = rect();

        const bool reverse = opt.direction == Qt::RightToLeft;
        const int menuButtonWidth = 12;
        const int rightSpacing = 10;
        const int right = !reverse ? r.right() - rightSpacing : r.left() + menuButtonWidth;
        const int height = r.height();

        QLine l1( 1, 0, right, height / 2 );
        QLine l2( 1, height, right, height / 2 );

        p.setRenderHint( QPainter::Antialiasing, true );

        // Draw the shadow
        QColor shadow( 0, 0, 0, 100 );
        p.translate( 0, 1 );
        p.setPen( shadow );
        p.drawLine( l1 );
        p.drawLine( l2 );

        // Draw the main arrow
        QColor foreGround( "#747474" );
        p.translate( 0, -1 );
        p.setPen( foreGround );
        p.drawLine( l1 );
        p.drawLine( l2 );
    }
开发者ID:pmpontes,项目名称:tomahawk,代码行数:31,代码来源:BreadcrumbButton.cpp

示例12: paintEvent

void ShowWidget::paintEvent(QPaintEvent *)
{
    QStyleOption op;
    op.initFrom(this);
    QPainter p(this);
    style()->drawPrimitive(QStyle::PE_Widget, &op, &p, this);
}
开发者ID:superAzalea,项目名称:qt_ocean,代码行数:7,代码来源:showwidget.cpp

示例13: drawBackground

/*!
  Draw the background of the canvas
  \param painter Painter
*/ 
void QwtPlotGLCanvas::drawBackground( QPainter *painter )
{
    painter->save();

    QWidget *w = qwtBGWidget( this );

    const QPoint off = mapTo( w, QPoint() );
    painter->translate( -off );

    const QRect fillRect = rect().translated( off );

    if ( w->testAttribute( Qt::WA_StyledBackground ) )
    {
        painter->setClipRect( fillRect );

        QStyleOption opt;
        opt.initFrom( w );
        w->style()->drawPrimitive( QStyle::PE_Widget, &opt, painter, w);
    }
    else 
    {
        painter->fillRect( fillRect,
            w->palette().brush( w->backgroundRole() ) );
    }

    painter->restore();
}
开发者ID:CaptainFalco,项目名称:OpenPilot,代码行数:31,代码来源:qwt_plot_glcanvas.cpp

示例14: paintEvent

void LXQtGroupPopup::paintEvent(QPaintEvent *event)
{
    QPainter p(this);
    QStyleOption opt;
    opt.initFrom(this);
    style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}
开发者ID:jsm222,项目名称:lxqt-panel,代码行数:7,代码来源:lxqtgrouppopup.cpp

示例15: borderPath

/*!
   Calculate the painter path for a styled or rounded border

   When the canvas has no styled background or rounded borders
   the painter path is empty.

   \param rect Bounding rectangle of the canvas
   \return Painter path, that can be used for clipping
*/
QPainterPath QwtPlotCanvas::borderPath( const QRect &rect ) const
{
    if ( testAttribute(Qt::WA_StyledBackground ) )
    {
        QwtStyleSheetRecorder recorder( rect.size() );

        QPainter painter( &recorder );

        QStyleOption opt;
        opt.initFrom(this);
        opt.rect = rect;
        style()->drawPrimitive( QStyle::PE_Widget, &opt, &painter, this);

        painter.end();

        if ( !recorder.background.path.isEmpty() )
            return recorder.background.path;

        if ( !recorder.border.rectList.isEmpty() )
            return qwtCombinePathList( rect, recorder.border.pathList );
    }
    else if ( d_data->borderRadius > 0.0 )
    {
        double fw2 = frameWidth() * 0.5;
        QRectF r = QRectF(rect).adjusted( fw2, fw2, -fw2, -fw2 );

        QPainterPath path;
        path.addRoundedRect( r, d_data->borderRadius, d_data->borderRadius );
        return path;
    }
    
    return QPainterPath();
}
开发者ID:Alex-Rongzhen-Huang,项目名称:OpenPilot,代码行数:42,代码来源:qwt_plot_canvas.cpp


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