|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.gui.QPainter
com.trolltech.qt.gui.QStylePainter
public class QStylePainter
The QStylePainter class is a convenience class for drawing QStyle elements inside a widget.
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:
void MyWidget::paintEvent(QPaintEvent * /* event *<!-- noop -->/)
{
QPainter painter(this);
QStyleOptionFocusRect option;
option.initFrom(this);
option.backgroundColor = palette().color(QPalette::Background);
style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, &painter, this);
}
Example using QStylePainter:
void MyWidget::paintEvent(QPaintEvent * /* event *<!-- noop -->/)
{
QStylePainter painter(this);
QStyleOptionFocusRect option;
option.initFrom(this);
option.backgroundColor = palette().color(QPalette::Background);
painter.drawPrimitive(QStyle::PE_FrameFocusRect, option);
}
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QPainter |
---|
QPainter.CompositionMode, QPainter.RenderHint, QPainter.RenderHints |
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I> |
Constructor Summary | |
---|---|
QStylePainter()
Constructs a QStylePainter. |
|
QStylePainter(QPaintDeviceInterface pd,
QWidget w)
Construct a QStylePainter using pd for its paint device, and attributes from w. |
|
QStylePainter(QWidget w)
Construct a QStylePainter using widget w for its paint device. |
Method Summary | |
---|---|
boolean |
begin(QPaintDeviceInterface pd,
QWidget w)
Begin painting operations on paint device pd as if it was w. |
boolean |
begin(QWidget w)
Begin painting operations on the specified w. |
void |
drawComplexControl(QStyle.ComplexControl cc,
QStyleOptionComplex opt)
Use the widget's style to draw a complex control cc specified by the QStyleOptionComplex opt. |
void |
drawControl(QStyle.ControlElement ce,
QStyleOption opt)
Use the widget's style to draw a control element ce specified by QStyleOption opt. |
void |
drawItemPixmap(QRect r,
int flags,
QPixmap pixmap)
Draws the pixmap in rectangle r. |
void |
drawItemText(QRect r,
int flags,
QPalette pal,
boolean enabled,
java.lang.String text)
Equivalent to drawItemText(r, flags, pal, enabled, text, QPalette::NoRole). |
void |
drawItemText(QRect r,
int flags,
QPalette pal,
boolean enabled,
java.lang.String text,
QPalette.ColorRole textRole)
Draws the text in rectangle r and palette pal. |
void |
drawPrimitive(QStyle.PrimitiveElement pe,
QStyleOption opt)
Use the widget's style to draw a primitive element pe specified by QStyleOption opt. |
static QStylePainter |
fromNativePointer(QNativePointer nativePointer)
This function returns the QStylePainter instance pointed to by nativePointer |
QStyle |
style()
Return the current style used by the QStylePainter. |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Constructor Detail |
---|
public QStylePainter()
Constructs a QStylePainter.
public QStylePainter(QWidget w)
Construct a QStylePainter using widget w for its paint device.
public QStylePainter(QPaintDeviceInterface pd, QWidget w)
Construct a QStylePainter using pd for its paint device, and attributes from w.
Method Detail |
---|
public final boolean begin(QPaintDeviceInterface pd, QWidget w)
Begin painting operations on paint device pd as if it was w.
This is automatically called by the constructor that takes a QPaintDevice and a QWidget.
public final boolean begin(QWidget w)
Begin painting operations on the specified w. Returns true if the painter is ready to use; otherwise returns false.
This is automatically called by the constructor that takes a QWidget.
begin
in class QPainter
public final void drawComplexControl(QStyle.ComplexControl cc, QStyleOptionComplex opt)
Use the widget's style to draw a complex control cc specified by the QStyleOptionComplex opt.
public final void drawControl(QStyle.ControlElement ce, QStyleOption opt)
Use the widget's style to draw a control element ce specified by QStyleOption opt.
public final void drawItemPixmap(QRect r, int flags, QPixmap pixmap)
Draws the pixmap in rectangle r. The pixmap is aligned according to flags.
Qt::Alignment
public final void drawItemText(QRect r, int flags, QPalette pal, boolean enabled, java.lang.String text)
Equivalent to drawItemText(r, flags, pal, enabled, text, QPalette::NoRole).
public final void drawItemText(QRect r, int flags, QPalette pal, boolean enabled, java.lang.String text, QPalette.ColorRole textRole)
Draws the text in rectangle r 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.
Qt::Alignment
public final void drawPrimitive(QStyle.PrimitiveElement pe, QStyleOption opt)
Use the widget's style to draw a primitive element pe specified by QStyleOption opt.
public final QStyle style()
Return the current style used by the QStylePainter.
public static QStylePainter fromNativePointer(QNativePointer nativePointer)
nativePointer
- the QNativePointer of which object should be returned.
|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |