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


C++ QStyleOptionComboBox类代码示例

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


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

示例1: subwidget

void KexiDBComboBox::createEditor()
{
    KexiDBAutoField::createEditor();
    if (subwidget()) {
        subwidget()->setGeometry(editorGeometry());
        if (!d->isEditable) {
            QStyleOptionComboBox option;
            option.initFrom(subwidget());
            const QRect comboRect = subwidget()->style()->subControlRect(
                QStyle::CC_ComboBox, &option, QStyle::SC_ComboBoxEditField, subwidget());
            kDebug() << "comboRect:" << comboRect;
            subwidget()->setContentsMargins(comboRect.left(), comboRect.top(),
                width() - comboRect.right(), height() - comboRect.bottom());
            int l, t, r, b;
            subwidget()->getContentsMargins(&l, &t, &r, &b);
            kDebug() << "altered margins:" << l << t << r << b;

            subwidget()->setFocusPolicy(Qt::NoFocus);
            subwidget()->setCursor(QCursor(Qt::ArrowCursor)); // widgets like listedit have IbeamCursor, we don't want that
            QPalette subwidgetPalette(subwidget()->palette());
            subwidgetPalette.setColor(QColorGroup::Base, Qt::transparent);
            subwidget()->setPalette(subwidgetPalette);
            d->subWidgetsWithDisabledEvents.clear();
            d->subWidgetsWithDisabledEvents << subwidget();
            subwidget()->installEventFilter(this);
            QList<QWidget*> widgets(subwidget()->findChildren<QWidget*>());
            foreach(QWidget *widget, widgets) {
                d->subWidgetsWithDisabledEvents << widget;
                widget->installEventFilter(this);
            }
        }
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:31,代码来源:kexidbcombobox.cpp

示例2: painter

void StatusChangeButton::paintEvent(QPaintEvent *event)
{
	QStylePainter painter(this);

	if(underMouse()) {
		QStyleOptionButton opt;
		opt.initFrom(this);

		if(isDown()) {
			opt.state |= QStyle::State_Sunken;
		}

		painter.drawControl(QStyle::CE_PushButton, opt);
	}

	painter.setPen(palette().color(QPalette::Text));

	QRect textRect = rect();
	textRect.moveLeft(iconSize().width() + 4);
	painter.drawText(textRect, Qt::AlignVCenter | Qt::TextSingleLine, text());

	painter.drawPixmap(QPoint(2, (height() - iconSize().height()) / 2), icon().pixmap(iconSize()));

	QStyleOptionComboBox opt;
	opt.initFrom(this);
	opt.rect = QRect(width() - 15, height() / 2 - 6, 11, 13);
	painter.drawPrimitive(QStyle::PE_IndicatorArrowDown, opt);
}
开发者ID:KittyIM,项目名称:Client,代码行数:28,代码来源:StatusChangeButton.cpp

示例3: p

void KexiDBComboBox::paintEvent(QPaintEvent *)
{
    QPainter p(this);
    p.setPen(palette().color(QPalette::Text));
//    QColorGroup cg(palette().active());
// if ( hasFocus() )
//  cg.setColor(QColorGroup::Base, cg.highlight());
// else
    QPalette pal(palette());
    pal.setColor(QColorGroup::Base, paletteBackgroundColor()); //update base color using (reimplemented) bg color

    if (width() < 5 || height() < 5) {
        qDrawShadePanel(&p, rect(), pal, false /* !sunken */,
                        2 /*line width*/, &pal.brush(QPalette::Button)/*fill*/);
        return;
    }

#ifdef __GNUC__
#warning TODO KexiDBComboBox::paintEvent()
#else
#pragma WARNING( TODO KexiDBComboBox::paintEvent() )
#endif

    QStyleOptionComboBox option;
    option.palette = pal;
    option.initFrom(d->paintedCombo);

    if (isEnabled())
        option.state |= QStyle::State_Enabled;
    if (hasFocus())
        option.state |= QStyle::State_HasFocus;
    if (d->mouseOver)
        option.state |= QStyle::State_MouseOver;

    style()->drawComplexControl(QStyle::CC_ComboBox, &option, &p, d->paintedCombo);

#if 0 //TODO
//! @todo support reverse layout
//bool reverse = QApplication::reverseLayout();
    style()->drawComplexControl(QStyle::CC_ComboBox, &option, &p, d->paintedCombo  /*this*/
                                flags, (uint)QStyle::SC_All,
                                (d->buttonPressed ? QStyle::SC_ComboBoxArrow : QStyle::SC_None)
                               );

    if (d->isEditable) {
        //if editable, editor paints itself, nothing to do
    } else { //not editable: we need to paint the current item
        QRect editorGeometry(this->editorGeometry());
        if (hasFocus()) {
            if (0 == qstrcmp(style()->name(), "windows")) //a hack
                p.fillRect(editorGeometry, cg.brush(QColorGroup::Highlight));
            QRect r(QStyle::visualRect(style()->subRect(QStyle::SR_ComboBoxFocusRect, d->paintedCombo), this));
            r = QRect(r.left() - 1, r.top() - 1, r.width() + 2, r.height() + 2); //enlare by 1 pixel each side to avoid covering by the subwidget
            style()->drawPrimitive(QStyle::PE_FocusRect, &p,
                                   r, cg, flags | QStyle::Style_FocusAtBorder, QStyleOption(cg.highlight()));
        }
        //todo
    }
#endif
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:60,代码来源:kexidbcombobox.cpp

示例4: QPoint

void KonqCombo::mousePressEvent( QMouseEvent *e )
{
    m_dragStart = QPoint(); // null QPoint

    if ( e->button() == Qt::LeftButton && !itemIcon( currentIndex()).isNull() ) {
        // check if the pixmap was clicked
        int x = e->pos().x();
        QStyleOptionComboBox comboOpt;
        getStyleOption(&comboOpt);
        int x0 = QStyle::visualRect( layoutDirection(), rect(),
            style()->subControlRect( QStyle::CC_ComboBox, &comboOpt, QStyle::SC_ComboBoxEditField,
                                     this ) ).x();

        if ( x > x0 + 2 && x < lineEdit()->x() ) {
            m_dragStart = e->pos();
            return; // don't call KComboBox::mousePressEvent!
        }
    }

    QStyleOptionComboBox optCombo;
    optCombo.initFrom(this);
    if ( e->button() == Qt::LeftButton && m_pageSecurity != KonqMainWindow::NotCrypted &&
         style()->subElementRect( QStyle::SE_ComboBoxFocusRect, &optCombo, this ).contains( e->pos() ) )
        emit showPageSecurity();

    KComboBox::mousePressEvent( e );
}
开发者ID:theunbelievablerepo,项目名称:dolphin2.1,代码行数:27,代码来源:konqcombo.cpp

示例5: paintEvent

void QmitkComboBoxListView::paintEvent(QPaintEvent *event)
{
  if (m_ComboBox != NULL)
  {
    QStyleOptionComboBox option;

    option.initFrom(m_ComboBox);
    option.editable = m_ComboBox->isEditable();

    if (m_ComboBox->style()->styleHint(QStyle::SH_ComboBox_Popup, &option, m_ComboBox))
    {
      QStyleOptionMenuItem menuOption;
      menuOption.initFrom(this);
      menuOption.palette = this->palette();
      menuOption.state = QStyle::State_None;
      menuOption.checkType = QStyleOptionMenuItem::NotCheckable;
      menuOption.menuRect = event->rect();
      menuOption.maxIconWidth = 0;
      menuOption.tabWidth = 0;

      QPainter painter(this->viewport());
      m_ComboBox->style()->drawControl(QStyle::CE_MenuEmptyArea, &menuOption, &painter, this);
    }
  }

  QListView::paintEvent(event);
}
开发者ID:pollen-metrology,项目名称:MITK,代码行数:27,代码来源:QmitkPropertyItemDelegate.cpp

示例6: Q_UNUSED

void ActionComboBoxWidget::paintEvent(QPaintEvent *event)
{
	Q_UNUSED(event);

	QPainter painter(this);
	QStyleOptionComboBox comboBoxOption;
	comboBoxOption.initFrom(this);
	comboBoxOption.editable = false;

	style()->drawComplexControl(QStyle::CC_ComboBox, &comboBoxOption, &painter, this);

	QStyleOptionViewItem viewItemOption;
	viewItemOption.initFrom(this);
	viewItemOption.displayAlignment |= Qt::AlignVCenter;

	if (currentIndex() >= 0)
	{
		itemDelegate()->paint(&painter, viewItemOption, m_view->getModel()->index(currentIndex(), 0));
	}
	else
	{
		const int textMargin = (style()->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, this) + 1);

		painter.setFont(viewItemOption.font);
		painter.drawText(viewItemOption.rect.adjusted(textMargin, 0, -textMargin, 0), Qt::AlignVCenter, tr("Select Action"));
	}
}
开发者ID:insionng,项目名称:otter-browser,代码行数:27,代码来源:ActionComboBoxWidget.cpp

示例7: mousePressEvent

void QgsDateTimeEdit::mousePressEvent( QMouseEvent *event )
{
  // catch mouse press on the button (when the current value is null)
  // in non-calendar mode: modifiy the date  so it leads to showing current date (don't bother about time)
  // in calendar mode: be sure NULL is displayed when needed and show page of current date in calendar widget

  bool updateCalendar = false;

  if ( mIsNull )
  {
    QStyle::SubControl control;
    if ( calendarPopup() )
    {
      QStyleOptionComboBox optCombo;
      optCombo.init( this );
      optCombo.editable = true;
      optCombo.subControls = QStyle::SC_All;
      control = style()->hitTestComplexControl( QStyle::CC_ComboBox, &optCombo, event->pos(), this );

      if ( control == QStyle::SC_ComboBoxArrow && calendarWidget() )
      {
        mCurrentPressEvent = true;
        // ensure the line edit still displays NULL
        updateCalendar = true;
        displayNull( updateCalendar );
        mCurrentPressEvent = false;
      }
    }
    else
    {
      QStyleOptionSpinBox opt;
      this->initStyleOption( &opt );
      control  = style()->hitTestComplexControl( QStyle::CC_SpinBox, &opt, event->pos(), this );

      if ( control == QStyle::SC_SpinBoxDown || control == QStyle::SC_SpinBoxUp )
      {
        mCurrentPressEvent = true;
        disconnect( this, &QDateTimeEdit::dateTimeChanged, this, &QgsDateTimeEdit::changed );
        resetBeforeChange( control == QStyle::SC_SpinBoxDown ? -1 : 1 );
        connect( this, &QDateTimeEdit::dateTimeChanged, this, &QgsDateTimeEdit::changed );
        mCurrentPressEvent = false;
      }
    }
  }

  QDateTimeEdit::mousePressEvent( event );

  if ( updateCalendar )
  {
    // set calendar page to current date to avoid going to minimal date page when value is null
    calendarWidget()->setCurrentPage( QDate::currentDate().year(), QDate::currentDate().month() );
  }
}
开发者ID:AlisterH,项目名称:Quantum-GIS,代码行数:53,代码来源:qgsdatetimeedit.cpp

示例8: mousePressEvent

void KoSliderComboContainer::mousePressEvent(QMouseEvent *e)
{
    QStyleOptionComboBox opt;
    opt.init(m_parent);
    opt.subControls = QStyle::SC_All;
    opt.activeSubControls = QStyle::SC_ComboBoxArrow;
    QStyle::SubControl sc = style()->hitTestComplexControl(QStyle::CC_ComboBox, &opt,
                                                           m_parent->mapFromGlobal(e->globalPos()),
                                                           m_parent);
    if (sc == QStyle::SC_ComboBoxArrow)
        setAttribute(Qt::WA_NoMouseReplay);
    QMenu::mousePressEvent(e);
}
开发者ID:KDE,项目名称:calligra-history,代码行数:13,代码来源:KoSliderCombo.cpp

示例9: gc

void KoSliderCombo::paintEvent(QPaintEvent *)
{
    QStylePainter gc(this);

    gc.setPen(palette().color(QPalette::Text));

    QStyleOptionComboBox opt;
    opt.init(this);
    opt.subControls = QStyle::SC_All;
    opt.editable = true;
    gc.drawComplexControl(QStyle::CC_ComboBox, opt);
    gc.drawControl(QStyle::CE_ComboBoxLabel, opt);
}
开发者ID:KDE,项目名称:calligra-history,代码行数:13,代码来源:KoSliderCombo.cpp

示例10: QComboBox

FlagBox::FlagBox(QWidget *parent)
    : QComboBox(parent)
{
    m_model = new FlagBoxModel(this);
    setModel(m_model);

    QStyleOptionComboBox opt;
    opt.initFrom(this);
    opt.editable = isEditable();
    if (style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, this))
        setItemDelegate(new QItemDelegate(this));

    connect(this, SIGNAL(activated(int)), this, SLOT(slotActivated(int)));
}
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:14,代码来源:flagbox.cpp

示例11: ensurePolished

QSize SqueezedComboBox::sizeHint() const
{
    ensurePolished();
    QFontMetrics fm = fontMetrics();

    int maxW = count() ? 18 : 7 * fm.width(QChar('x')) + 18;
    int maxH = qMax(fm.lineSpacing(), 14) + 2;

    QStyleOptionComboBox options;
    options.initFrom(this);

    return style()->sizeFromContents(QStyle::CT_ComboBox, &options,
                                     QSize(maxW, maxH), this).expandedTo(QApplication::globalStrut());
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:14,代码来源:squeezedcombobox.cpp

示例12: registerPerspective

void DebuggerMainWindow::registerPerspective(const QByteArray &perspectiveId, const Perspective &perspective)
{
    m_perspectiveForPerspectiveId.insert(perspectiveId, perspective);
    m_perspectiveChooser->addItem(perspective.name(), perspectiveId);
    // adjust width if necessary
    const int oldWidth = m_perspectiveChooser->width();
    const int contentWidth = m_perspectiveChooser->fontMetrics().width(perspective.name());
    QStyleOptionComboBox option;
    option.initFrom(m_perspectiveChooser);
    const QSize sz(contentWidth, 1);
    const int width = m_perspectiveChooser->style()->sizeFromContents(
                QStyle::CT_ComboBox, &option, sz).width();
    if (width > oldWidth)
        m_perspectiveChooser->setFixedWidth(width);
}
开发者ID:tomba,项目名称:qt-creator,代码行数:15,代码来源:debuggermainwindow.cpp

示例13: fontMetrics

QSize KoSliderCombo::minimumSizeHint() const
{
    QSize sh;

    const QFontMetrics &fm = fontMetrics();

    sh.setWidth(5 * fm.width(QLatin1Char('8')));
    sh.setHeight(qMax(fm.lineSpacing(), 14) + 2);

    // add style and strut values
    QStyleOptionComboBox opt;
    opt.init(this);
    opt.subControls = QStyle::SC_All;
    opt.editable = true;
    sh = style()->sizeFromContents(QStyle::CT_ComboBox, &opt, sh, this);

    return sh.expandedTo(QApplication::globalStrut());
}
开发者ID:KDE,项目名称:calligra-history,代码行数:18,代码来源:KoSliderCombo.cpp

示例14: painter

void StatusArrowButton::paintEvent(QPaintEvent *event)
{
	QStylePainter painter(this);

	if(underMouse()) {
		QStyleOptionButton opt;
		opt.initFrom(this);

		if(isDown()) {
			opt.state |= QStyle::State_Sunken;
		}

		painter.drawControl(QStyle::CE_PushButton, opt);
	}

	QStyleOptionComboBox opt;
	opt.initFrom(this);
	opt.rect = QRect(width() - 15, height() / 2 - 6, 11, 13);
	painter.drawPrimitive(QStyle::PE_IndicatorArrowDown, opt);
}
开发者ID:KittyIM,项目名称:Client,代码行数:20,代码来源:StatusTextWidget.cpp

示例15: p

bool RenderThemeQt::paintMenuListButton(RenderObject* o, const RenderObject::PaintInfo& i,
                                        const IntRect& r)
{
    StylePainter p(i);
    if (!p.isValid())
        return true;

    QStyleOptionComboBox option;
    if (p.widget)
        option.initFrom(p.widget);
    applyTheme(option, o);
    option.rect = r;

    // for drawing the combo box arrow, rely only on the fallback style
    p.style = fallbackStyle();
    option.subControls = QStyle::SC_ComboBoxArrow;
    p.drawComplexControl(QStyle::CC_ComboBox, option);

    return false;
}
开发者ID:Chingliu,项目名称:EAWebkit,代码行数:20,代码来源:RenderThemeQt.cpp


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