#include <qstylepainter.h>
Inheritance diagram for QStylePainter:


QStylePainter extends QPainter with a set of high-level draw...() functions implemented on top of QStyle's API. The advantage of using QStylePainter 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 QStylePainter 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:
snippets/styles/styles.cpp paintEvent( }
Example using QStylePainter:
snippets/styles/styles.cpp paintEvent( paintEvent paintEvent2( { }
Definition at line 35 of file qstylepainter.h.
Public Member Functions | |
| QStylePainter () | |
| QStylePainter (QWidget *w) | |
| QStylePainter (QPaintDevice *pd, QWidget *w) | |
| bool | begin (QWidget *w) |
| bool | begin (QPaintDevice *pd, QWidget *w) |
| void | drawPrimitive (QStyle::PrimitiveElement pe, const QStyleOption &opt) |
| void | drawControl (QStyle::ControlElement ce, const QStyleOption &opt) |
| void | drawComplexControl (QStyle::ComplexControl cc, const QStyleOptionComplex &opt) |
| void | drawItemText (const QRect &r, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole=QPalette::NoRole) |
| void | drawItemPixmap (const QRect &r, int flags, const QPixmap &pixmap) |
| QStyle * | style () const |
Private Attributes | |
| QWidget * | widget |
| QStyle * | wstyle |
| QStylePainter::QStylePainter | ( | ) | [inline] |
| QStylePainter::QStylePainter | ( | QWidget * | widget | ) | [inline, explicit] |
Construct a QStylePainter using widget widget for its paint device.
Definition at line 39 of file qstylepainter.h.
References w.
| QStylePainter::QStylePainter | ( | QPaintDevice * | pd, | |
| QWidget * | widget | |||
| ) | [inline] |
Construct a QStylePainter using pd for its paint device, and attributes from widget.
Definition at line 40 of file qstylepainter.h.
References w.
| bool QStylePainter::begin | ( | QWidget * | widget | ) | [inline] |
| bool QStylePainter::begin | ( | QPaintDevice * | pd, | |
| QWidget * | widget | |||
| ) | [inline] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. 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.
Definition at line 42 of file qstylepainter.h.
References QPainter::begin(), and w.
00042 { 00043 Q_ASSERT_X(w, "QStylePainter::QStylePainter", "Widget must be non-zero"); 00044 widget = w; 00045 wstyle = w->style(); 00046 return QPainter::begin(pd); 00047 };
Here is the call graph for this function:

| void QStylePainter::drawPrimitive | ( | QStyle::PrimitiveElement | pe, | |
| const QStyleOption & | option | |||
| ) | [inline] |
Use the widget's style to draw a primitive element pe specified by QStyleOption option.
Definition at line 62 of file qstylepainter.h.
References QStyle::drawPrimitive(), widget, and wstyle.
00063 { 00064 wstyle->drawPrimitive(pe, &opt, this, widget); 00065 }
Here is the call graph for this function:

| void QStylePainter::drawControl | ( | QStyle::ControlElement | ce, | |
| const QStyleOption & | option | |||
| ) | [inline] |
Use the widget's style to draw a control element ce specified by QStyleOption option.
Definition at line 67 of file qstylepainter.h.
References QStyle::drawControl(), widget, and wstyle.
Referenced by QComboBox::paintEvent(), QRubberBand::paintEvent(), and QProgressBar::paintEvent().
00068 { 00069 wstyle->drawControl(ce, &opt, this, widget); 00070 }
Here is the call graph for this function:

| void QStylePainter::drawComplexControl | ( | QStyle::ComplexControl | cc, | |
| const QStyleOptionComplex & | option | |||
| ) | [inline] |
Use the widget's style to draw a complex control cc specified by the QStyleOptionComplex option.
Definition at line 72 of file qstylepainter.h.
References QStyle::drawComplexControl(), widget, and wstyle.
Referenced by QComboBox::paintEvent(), and QGroupBox::paintEvent().
00073 { 00074 wstyle->drawComplexControl(cc, &opt, this, widget); 00075 }
Here is the call graph for this function:

| void QStylePainter::drawItemText | ( | const QRect & | rect, | |
| int | flags, | |||
| const QPalette & | pal, | |||
| bool | enabled, | |||
| const QString & | text, | |||
| QPalette::ColorRole | textRole = QPalette::NoRole | |||
| ) | [inline] |
Draws the text in rectangle rect and palette pal. The text is aligned and wrapped according to flags.
The pen color is specified with textRole. The enabled bool indicates whether or not the item is enabled; when reimplementing this bool should influence how the item is drawn.
Definition at line 77 of file qstylepainter.h.
References QStyle::drawItemText(), and wstyle.
00079 { 00080 wstyle->drawItemText(this, r, flags, pal, enabled, text, textRole); 00081 }
Here is the call graph for this function:

| void QStylePainter::drawItemPixmap | ( | const QRect & | rect, | |
| int | flags, | |||
| const QPixmap & | pixmap | |||
| ) | [inline] |
Draws the pixmap in rectangle rect. The pixmap is aligned according to flags.
Definition at line 83 of file qstylepainter.h.
References QStyle::drawItemPixmap(), and wstyle.
00084 { 00085 wstyle->drawItemPixmap(this, r, flags, pixmap); 00086 }
Here is the call graph for this function:

| QStyle * QStylePainter::style | ( | ) | const [inline] |
Return the current style used by the QStylePainter.
Definition at line 54 of file qstylepainter.h.
00054 { return wstyle; }
QWidget* QStylePainter::widget [private] |
Definition at line 57 of file qstylepainter.h.
Referenced by drawComplexControl(), drawControl(), and drawPrimitive().
QStyle* QStylePainter::wstyle [private] |
Definition at line 58 of file qstylepainter.h.
Referenced by drawComplexControl(), drawControl(), drawItemPixmap(), drawItemText(), and drawPrimitive().
1.5.1