本文整理汇总了C++中QStyleOptionFocusRect类的典型用法代码示例。如果您正苦于以下问题:C++ QStyleOptionFocusRect类的具体用法?C++ QStyleOptionFocusRect怎么用?C++ QStyleOptionFocusRect使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QStyleOptionFocusRect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: painter
void QIRichToolButton::paintEvent (QPaintEvent *aEvent)
{
/* Draw focus around mLabel if focused */
if (hasFocus())
{
QStylePainter painter (this);
QStyleOptionFocusRect option;
option.initFrom (this);
option.rect = mLabel->frameGeometry();
painter.drawPrimitive (QStyle::PE_FrameFocusRect, option);
}
QWidget::paintEvent (aEvent);
}
示例2: Q_UNUSED
void KItemListWidget::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
Q_UNUSED(option);
if (m_alternateBackground) {
const QColor backgroundColor = m_styleOption.palette.color(QPalette::AlternateBase);
const QRectF backgroundRect(0, 0, size().width(), size().height());
painter->fillRect(backgroundRect, backgroundColor);
}
if (m_selected && m_editedRole.isEmpty()) {
const QStyle::State activeState(isActiveWindow() ? QStyle::State_Active : 0);
drawItemStyleOption(painter, widget, activeState |
QStyle::State_Enabled |
QStyle::State_Selected |
QStyle::State_Item);
}
if (m_current && m_editedRole.isEmpty()) {
QStyleOptionFocusRect focusRectOption;
focusRectOption.initFrom(widget);
focusRectOption.rect = textFocusRect().toRect();
focusRectOption.state = QStyle::State_Enabled | QStyle::State_Item | QStyle::State_KeyboardFocusChange;
if (m_selected) {
focusRectOption.state |= QStyle::State_Selected;
}
style()->drawPrimitive(QStyle::PE_FrameFocusRect, &focusRectOption, painter, widget);
}
if (m_hoverOpacity > 0.0) {
if (!m_hoverCache) {
// Initialize the m_hoverCache pixmap to improve the drawing performance
// when fading the hover background
m_hoverCache = new QPixmap(size().toSize());
m_hoverCache->fill(Qt::transparent);
QPainter pixmapPainter(m_hoverCache);
const QStyle::State activeState(isActiveWindow() ? QStyle::State_Active : 0);
drawItemStyleOption(&pixmapPainter, widget, activeState |
QStyle::State_Enabled |
QStyle::State_MouseOver |
QStyle::State_Item);
}
const qreal opacity = painter->opacity();
painter->setOpacity(m_hoverOpacity * opacity);
painter->drawPixmap(0, 0, *m_hoverCache);
painter->setOpacity(opacity);
}
}
示例3: paintEvent
void paintEvent( QPaintEvent* /*pPaintEvent*/ )
{
if( m_Selected )
{
QStyle* style = this->style();
QStyleOptionFocusRect option;
option.initFrom( this );
option.rect.adjust( 2, 2, -2, -2 );
QPainter painter( this );
style->drawPrimitive( QStyle::PE_FrameFocusRect, &option, &painter, this );
}
}
示例4: drawItemHighlighter
QRect KexiRelationsTableFieldList::drawItemHighlighter(QPainter *painter, Q3ListViewItem *item)
{
#ifdef __GNUC__
#warning TODO KexiRelationsTableFieldList::drawItemHighlighter() OK?
#endif
if (painter) {
QStyleOptionFocusRect option;
option.initFrom(this);
option.rect = itemRect(item);
option.state |= QStyle::State_FocusAtBorder;
style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, painter, this);
}
return itemRect(item);
}
示例5: painter
/*!
\reimp
*/
void QxtStars::paintEvent(QPaintEvent* event)
{
QAbstractSlider::paintEvent(event);
QPainter painter(this);
painter.save();
painter.setPen(palette().color(QPalette::Text));
painter.setRenderHint(QPainter::Antialiasing);
const bool invert = invertedAppearance();
const QSize size = qxt_d().getStarSize();
const QRectF star = qxt_d().star.boundingRect();
painter.scale(size.width() / star.width(), size.height() / star.height());
const int count = maximum() - minimum();
if (orientation() == Qt::Horizontal)
{
painter.translate(-star.x(), -star.y());
if (invert != isRightToLeft())
painter.translate((count - 1) * star.width(), 0);
}
else
{
painter.translate(-star.x(), -star.y());
if (!invert)
painter.translate(0, (count - 1) * star.height());
}
for (int i = 0; i < count; ++i)
{
if (value() > minimum() + i)
painter.setBrush(palette().highlight());
else
painter.setBrush(palette().base());
painter.drawPath(qxt_d().star);
if (orientation() == Qt::Horizontal)
painter.translate(invert != isRightToLeft() ? -star.width() : star.width(), 0);
else
painter.translate(0, invert ? star.height() : -star.height());
}
painter.restore();
if (hasFocus())
{
QStyleOptionFocusRect opt;
opt.initFrom(this);
opt.rect.setSize(sizeHint());
style()->drawPrimitive(QStyle::PE_FrameFocusRect, &opt, &painter, this);
}
}
示例6: painter
void Plotter::paintEvent(QPaintEvent * /* event */)
{
QStylePainter painter(this);
painter.drawPixmap(0, 0, pixmap);
if (rubberBandIsShown) {
painter.setPen(palette().light().color());
painter.drawRect(rubberBandRect.normalized().adjusted(0, 0, -1, -1));
}
if (hasFocus()) {
QStyleOptionFocusRect option;
option.initFrom(this);
option.backgroundColor = palette().dark().color();
painter.drawPrimitive(QStyle::PE_FrameFocusRect, option);
}
}
示例7: drawFocusRect
void QwtPainter::drawFocusRect(QPainter *painter, QWidget *widget,
const QRect &rect)
{
#if QT_VERSION < 0x040000
widget->style().drawPrimitive(QStyle::PE_FocusRect, painter,
rect, widget->colorGroup());
#else
QStyleOptionFocusRect opt;
opt.init(widget);
opt.rect = rect;
opt.state |= QStyle::State_HasFocus;
widget->style()->drawPrimitive(QStyle::PE_FrameFocusRect,
&opt, painter, widget);
#endif
}
示例8: p
void StarWidget::paintEvent(QPaintEvent *event)
{
QPainter p(this);
for (int i = 0; i < current; i++)
p.drawPixmap(i * IMG_SIZE + SPACING, 0, starActive());
for (int i = current; i < TOTALSTARS; i++)
p.drawPixmap(i * IMG_SIZE + SPACING, 0, starInactive());
if (hasFocus()) {
QStyleOptionFocusRect option;
option.initFrom(this);
option.backgroundColor = palette().color(QPalette::Background);
style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, &p, this);
}
}
示例9: rect
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);
}
示例10: painter
void Plotter::paintEvent(QPaintEvent *pEvent)
{
//Q_UNUSED(pEvent);
QStylePainter painter(this);
QColor l_objColor;
painter.drawPixmap(0,0,pixmap);
if(rubberBandIsShown)
{
painter.setPen(palette().light().color());
painter.setBackgroundMode(Qt::TransparentMode);
painter.fillRect(rubberBandRect,Qt::NoBrush);
painter.drawRect(rubberBandRect.normalized());
}
if(hasFocus())
{
QStyleOptionFocusRect option;
option.initFrom(this);
option.backgroundColor = palette().dark().color();
painter.drawPrimitive(QStyle::PE_FrameFocusRect,option);
}
}
示例11: p
void BcLabel::paintEvent(QPaintEvent * event)
{
// draw underlining if clickable
if (!m_last && m_hover) {
QPainter p(this);
p.setPen(QPen(QPalette().highlight().color(), 1));
p.drawLine(0, height() - 2, width(), height() - 2);
}
// unbreak painting
QLabel::paintEvent(event);
// focus handling
if (hasFocus()) {
QPainter p(this);
QStyleOptionFocusRect opt;
opt.initFrom(this);
opt.backgroundColor = Qt::white;
style()->drawPrimitive(QStyle::PE_FrameFocusRect, &opt, &p, this);
}
}
示例12: Q_D
void KisAbstractSliderSpinBox::paintEvent(QPaintEvent* e)
{
Q_D(KisAbstractSliderSpinBox);
Q_UNUSED(e)
QPainter painter(this);
//Create options to draw spin box parts
QStyleOptionSpinBox spinOpts = spinBoxOptions();
//Draw "SpinBox".Clip off the area of the lineEdit to avoid double
//borders being drawn
painter.save();
painter.setClipping(true);
QRect eraseRect(QPoint(rect().x(), rect().y()),
QPoint(progressRect(spinOpts).right(), rect().bottom()));
painter.setClipRegion(QRegion(rect()).subtracted(eraseRect));
style()->drawComplexControl(QStyle::CC_SpinBox, &spinOpts, &painter, d->dummySpinBox);
painter.setClipping(false);
painter.restore();
//Create options to draw progress bar parts
QStyleOptionProgressBar progressOpts = progressBarOptions();
//Draw "ProgressBar" in SpinBox
style()->drawControl(QStyle::CE_ProgressBar, &progressOpts, &painter, 0);
//Draw focus if necessary
if (hasFocus() &&
d->edit->hasFocus()) {
QStyleOptionFocusRect focusOpts;
focusOpts.initFrom(this);
focusOpts.rect = progressOpts.rect;
focusOpts.backgroundColor = palette().color(QPalette::Window);
style()->drawPrimitive(QStyle::PE_FrameFocusRect, &focusOpts, &painter, this);
}
}
示例13: p
void StarWidget::paintEvent(QPaintEvent *event)
{
QPainter p(this);
QImage star = hasFocus() ? focusedImage(starActive()) : starActive();
QPixmap selected = QPixmap::fromImage(star);
QPixmap inactive = QPixmap::fromImage(starInactive());
const IconMetrics& metrics = defaultIconMetrics();
for (int i = 0; i < current; i++)
p.drawPixmap(i * metrics.sz_small + metrics.spacing, 0, selected);
for (int i = current; i < TOTALSTARS; i++)
p.drawPixmap(i * metrics.sz_small + metrics.spacing, 0, inactive);
if (hasFocus()) {
QStyleOptionFocusRect option;
option.initFrom(this);
option.backgroundColor = palette().color(QPalette::Background);
style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, &p, this);
}
}
示例14: painter
void ColorButton::paintEvent( QPaintEvent * )
{
QPainter painter(this);
//First, we need to draw the bevel.
QStyleOptionButton butOpt;
initStyleOption(&butOpt);
style()->drawControl( QStyle::CE_PushButtonBevel, &butOpt, &painter, this );
//OK, now we can muck around with drawing out pretty little color box
//First, sort out where it goes
QRect labelRect = style()->subElementRect( QStyle::SE_PushButtonContents,
&butOpt, this );
int shift = style()->pixelMetric( QStyle::PM_ButtonMargin );
labelRect.adjust(shift, shift, -shift, -shift);
int x, y, w, h;
labelRect.getRect(&x, &y, &w, &h);
if (isChecked() || isDown()) {
x += style()->pixelMetric( QStyle::PM_ButtonShiftHorizontal );
y += style()->pixelMetric( QStyle::PM_ButtonShiftVertical );
}
QColor fillCol = isEnabled() ? btnColor : palette().color(backgroundRole());
qDrawShadePanel( &painter, x, y, w, h, palette(), true, 1, NULL);
if ( fillCol.isValid() )
painter.fillRect( x+1, y+1, w-2, h-2, fillCol );
if ( hasFocus() ) {
QRect focusRect = style()->subElementRect( QStyle::SE_PushButtonFocusRect, &butOpt, this );
QStyleOptionFocusRect focusOpt;
focusOpt.init(this);
focusOpt.rect = focusRect;
focusOpt.backgroundColor = palette().background().color();
style()->drawPrimitive( QStyle::PE_FrameFocusRect, &focusOpt, &painter, this );
}
}
示例15: p
void DetailsButton::paintEvent(QPaintEvent *e)
{
QWidget::paintEvent(e);
QPainter p(this);
// draw hover animation
if (!HostOsInfo::isMacHost() && !isDown() && m_fader > 0) {
QColor c = creatorTheme()->color(Theme::DetailsButtonBackgroundColorHover);
c.setAlpha (int(m_fader * c.alpha()));
QRect r = rect();
if (!creatorTheme()->flag(Theme::FlatProjectsMode))
r.adjust(1, 1, -2, -2);
p.fillRect(r, c);
}
if (isChecked()) {
if (m_checkedPixmap.isNull() || m_checkedPixmap.size() / m_checkedPixmap.devicePixelRatio() != contentsRect().size())
m_checkedPixmap = cacheRendering(contentsRect().size(), true);
p.drawPixmap(contentsRect(), m_checkedPixmap);
} else {
if (m_uncheckedPixmap.isNull() || m_uncheckedPixmap.size() / m_uncheckedPixmap.devicePixelRatio() != contentsRect().size())
m_uncheckedPixmap = cacheRendering(contentsRect().size(), false);
p.drawPixmap(contentsRect(), m_uncheckedPixmap);
}
if (isDown()) {
p.setPen(Qt::NoPen);
p.setBrush(QColor(0, 0, 0, 20));
p.drawRoundedRect(rect().adjusted(1, 1, -1, -1), 1, 1);
}
if (hasFocus()) {
QStyleOptionFocusRect option;
option.initFrom(this);
style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, &p, this);
}
}