Use QStylePainter when painting widgets
This makes it easier to set global painter options which affect all style painting. Change-Id: I6a38204ed2d874255e92345e6a6a50d27939fb24 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
321e51d926
commit
3ad4fff7d5
@ -51,6 +51,7 @@
|
||||
#include <qlayout.h>
|
||||
#include <qset.h>
|
||||
#include <qstyle.h>
|
||||
#include <qstylepainter.h>
|
||||
#if QT_CONFIG(timezone)
|
||||
#include <QTimeZone>
|
||||
#endif
|
||||
@ -2441,8 +2442,8 @@ void QDateTimeEdit::paintEvent(QPaintEvent *event)
|
||||
optCombo.state &= ~QStyle::State_Enabled;
|
||||
}
|
||||
|
||||
QPainter p(this);
|
||||
style()->drawComplexControl(QStyle::CC_ComboBox, &optCombo, &p, this);
|
||||
QStylePainter p(this);
|
||||
p.drawComplexControl(QStyle::CC_ComboBox, optCombo);
|
||||
}
|
||||
|
||||
int QDateTimeEditPrivate::absoluteIndex(QDateTimeEdit::Section s, int index) const
|
||||
|
@ -219,7 +219,7 @@ void QDockWidgetTitleButton::leaveEvent(QEvent *event)
|
||||
|
||||
void QDockWidgetTitleButton::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter p(this);
|
||||
QStylePainter p(this);
|
||||
|
||||
QStyleOptionToolButton opt;
|
||||
opt.initFrom(this);
|
||||
@ -232,7 +232,7 @@ void QDockWidgetTitleButton::paintEvent(QPaintEvent *)
|
||||
opt.state |= QStyle::State_On;
|
||||
if (isDown())
|
||||
opt.state |= QStyle::State_Sunken;
|
||||
style()->drawPrimitive(QStyle::PE_PanelButtonTool, &opt, &p, this);
|
||||
p.drawPrimitive(QStyle::PE_PanelButtonTool, opt);
|
||||
} else if (isDown() || isChecked()) {
|
||||
// no frame, but the icon might have explicit pixmaps for QIcon::On
|
||||
opt.state |= QStyle::State_On | QStyle::State_Sunken;
|
||||
@ -244,7 +244,7 @@ void QDockWidgetTitleButton::paintEvent(QPaintEvent *)
|
||||
opt.features = QStyleOptionToolButton::None;
|
||||
opt.arrowType = Qt::NoArrow;
|
||||
opt.iconSize = dockButtonIconSize();
|
||||
style()->drawComplexControl(QStyle::CC_ToolButton, &opt, &p, this);
|
||||
p.drawComplexControl(QStyle::CC_ToolButton, opt);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include "qpainter.h"
|
||||
#include "qstyle.h"
|
||||
#include "qstyleoption.h"
|
||||
#include "qstylepainter.h"
|
||||
#include "qapplication.h"
|
||||
|
||||
#include "qframe_p.h"
|
||||
@ -511,8 +512,8 @@ QSize QFrame::sizeHint() const
|
||||
|
||||
void QFrame::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter paint(this);
|
||||
drawFrame(&paint);
|
||||
QStylePainter p(this);
|
||||
drawFrame(&p);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include "qscrollbar.h"
|
||||
#include "qstyle.h"
|
||||
#include "qstyleoption.h"
|
||||
#include "qstylepainter.h"
|
||||
#if QT_CONFIG(menu)
|
||||
#include "qmenu.h"
|
||||
#endif
|
||||
@ -525,7 +526,7 @@ void QScrollBar::wheelEvent(QWheelEvent *event)
|
||||
void QScrollBar::paintEvent(QPaintEvent *)
|
||||
{
|
||||
Q_D(QScrollBar);
|
||||
QPainter p(this);
|
||||
QStylePainter p(this);
|
||||
QStyleOptionSlider opt;
|
||||
initStyleOption(&opt);
|
||||
opt.subControls = QStyle::SC_All;
|
||||
@ -536,7 +537,7 @@ void QScrollBar::paintEvent(QPaintEvent *)
|
||||
} else {
|
||||
opt.activeSubControls = (QStyle::SubControl)d->hoverControl;
|
||||
}
|
||||
style()->drawComplexControl(QStyle::CC_ScrollBar, &opt, &p, this);
|
||||
p.drawComplexControl(QStyle::CC_ScrollBar, opt);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include "qpainter.h"
|
||||
#include "qstyle.h"
|
||||
#include "qstyleoption.h"
|
||||
#include "qstylepainter.h"
|
||||
#include "private/qapplication_p.h"
|
||||
#include "private/qabstractslider_p.h"
|
||||
#include "qdebug.h"
|
||||
@ -317,7 +318,7 @@ QSlider::~QSlider()
|
||||
void QSlider::paintEvent(QPaintEvent *)
|
||||
{
|
||||
Q_D(QSlider);
|
||||
QPainter p(this);
|
||||
QStylePainter p(this);
|
||||
QStyleOptionSlider opt;
|
||||
initStyleOption(&opt);
|
||||
|
||||
@ -325,7 +326,7 @@ void QSlider::paintEvent(QPaintEvent *)
|
||||
if (d->tickPosition != NoTicks)
|
||||
opt.subControls |= QStyle::SC_SliderTickmarks;
|
||||
|
||||
style()->drawComplexControl(QStyle::CC_Slider, &opt, &p, this);
|
||||
p.drawComplexControl(QStyle::CC_Slider, opt);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
Loading…
Reference in New Issue
Block a user