QStylePainter Class▲
-
Header: QStylePainter
-
qmake: QT += widgets
-
Group: QStylePainter is part of appearance, painting
Detailed Description▲
https:// extends QPainter with a set of high-level draw...() functions implemented on top of QStyle's API. The advantage of using https:// is that the parameter lists get considerably shorter. Whereas a QStyle object must be able to draw on any widget using any painter (because the application normally has one QStyle object shared by all widget), a https:// is initialized with a widget, eliminating the need to specify the QWidget, the QPainter, and the QStyle for every function call.
Example using QStyle directly:
void MyWidget::paintEvent(QPaintEvent * /* event */)
{
QPainter painter(this);
QStyleOptionFocusRect option;
option.initFrom(this);
option.backgroundColor = palette().color(QPalette::Background);
style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, &painter, this);
}Example using https://:
void MyWidget::paintEvent(QPaintEvent * /* event */)
{
QStylePainter painter(this);
QStyleOptionFocusRect option;
option.initFrom(this);
option.backgroundColor = palette().color(QPalette::Background);
painter.drawPrimitive(QStyle::PE_FrameFocusRect, option);
}See Also▲
See also QStyle, https://
Member Function Documentation▲
QStylePainter::QStylePainter()▲
Constructs a https://.
[explicit] QStylePainter::QStylePainter(QWidget *widget)▲
Construct a https:// using widget widget for its paint device.
QStylePainter::QStylePainter(int *pd, QWidget *widget)▲
Construct a https:// using pd for its paint device, and attributes from widget.
bool QStylePainter::begin(QWidget *widget)▲
Begin painting operations on the specified widget. Returns true if the painter is ready to use; otherwise returns false.
This is automatically called by the constructor that takes a QWidget.
bool QStylePainter::begin(int *pd, QWidget *widget)▲
This is an overloaded function.
Begin painting operations on paint device pd as if it was widget.
This is automatically called by the constructor that takes a QPaintDevice and a QWidget.
void QStylePainter::drawControl(int ce, const QStyleOption &option)▲
Use the widget's style to draw a control element ce specified by QStyleOption option.
See Also▲
See also QStyle::drawControl()
void QStylePainter::drawItemPixmap(const QRect &rect, int flags, const QPixmap &pixmap)▲
Draws the pixmap in rectangle rect. The pixmap is aligned according to flags.
See Also▲
See also QStyle::drawItemPixmap(), Qt::Alignment
void QStylePainter::drawPrimitive(int pe, const QStyleOption &option)▲
Use the widget's style to draw a primitive element pe specified by QStyleOption option.
See Also▲
See also QStyle::drawPrimitive()
QStyle *QStylePainter::style() const▲
Return the current style used by the https://.


