|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.internal.QSignalEmitterInternal
com.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.core.QObject
com.trolltech.qt.gui.QStyle
public abstract class QStyle
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI. Qt contains a set of QStyle subclasses that emulate the styles of the different platforms supported by Qt (QWindowsStyle
, QMacStyle, QMotifStyle
, etc.). By default, these styles are built into the QtGui library. Styles can also be made available as plugins.
Qt's built-in widgets use QStyle to perform nearly all of their drawing, ensuring that they look exactly like the equivalent native widgets. The diagram below shows a QComboBox
in eight different styles.
QApplication::setStyle()
function. It can also be specified by the user of the application, using the -style command-line option: ./myapplication -style motifIf no style is specified, Qt will choose the most appropriate style for the user's platform or desktop environment.
A style can also be set on an individual widget using the QWidget::setStyle()
function.Developing Style-Aware Custom Widgets
If you are developing custom widgets and want them to look good on all platforms, you can use QStyle functions to perform parts of the widget drawing, such as drawItemText()
, drawItemPixmap()
, drawPrimitive()
, drawControl()
, and drawComplexControl()
.
Most QStyle draw functions take four arguments:
QStyleOption
specifying how and where to render that elementQPainter
that should be used to draw the elementQWidget
on which the drawing is performed (optional)protected void paintEvent(QPaintEvent event) { QPainter painter = new QPainter(this); QStyleOptionFocusRect option = new QStyleOptionFocusRect(); option.initFrom(this); option.setBackgroundColor(palette().color(QPalette.ColorRole.Window)); style().drawPrimitive(QStyle.PrimitiveElement.PE_FrameFocusRect, option, painter, this); }QStyle gets all the information it needs to render the graphical element from
QStyleOption
. The widget is passed as the last argument in case the style needs it to perform special effects (such as animated default buttons on Mac OS X), but it isn't mandatory. In fact, you can use QStyle to draw on any paint device, not just widgets, by setting the QPainter
properly. QStyleOption
has various subclasses for the various types of graphical elements that can be drawn. For example, PE_FrameFocusRect
expects a QStyleOptionFocusRect
argument.
To ensure that drawing operations are as fast as possible, QStyleOption
and its subclasses have public data members. See the QStyleOption
class documentation for details on how to use it.
For convenience, Qt provides the QStylePainter
class, which combines a QStyle, a QPainter
, and a QWidget
. This makes it possible to write
QStylePainter painter = new QStylePainter(this); ... painter.drawPrimitive(QStyle.PrimitiveElement.PE_FrameFocusRect, option);instead of
QPainter painter = new QPainter(this); ... style().drawPrimitive(QStyle.PrimitiveElement.PE_FrameFocusRect, option, painter, this);
QCommonStyle
(and not QStyle). This is because Qt requires its styles to be QCommonStyle
s. Depending on which parts of the base style you want to change, you must reimplement the functions that are used to draw those parts of the interface. To illustrate this, we will modify the look of the spin box arrows drawn by QWindowsStyle
. The arrows are primitive elements that are drawn by the drawPrimitive()
function, so we need to reimplement that function. We need the following class declaration:
public class CustomStyle extends QWindowsStyle { public CustomStyle() { ... } public void drawPrimitive(QStyle.PrimitiveElement element, QStyleOption option, QPainter painter, QWidget widget) { ... } }To draw its up and down arrows,
QSpinBox
uses the PE_IndicatorSpinUp
and PE_IndicatorSpinDown
primitive elements. Here's how to reimplement the drawPrimitive()
function to draw them differently: public void drawPrimitive(QStyle.PrimitiveElement element, QStyleOption option, QPainter painter, QWidget widget) { if (element.equals(QStyle.PrimitiveElement.PE_IndicatorSpinUp) || element.equals(QStyle.PrimitiveElement.PE_IndicatorSpinDown)) { QPolygon points = new QPolygon(3); int x = option.rect().x(); int y = option.rect().y(); int w = option.rect().width() / 2; int h = option.rect().height() / 2; x += (option.rect().width() - w) / 2; y += (option.rect().height() - h) / 2; if (element.equals(QStyle.PrimitiveElement.PE_IndicatorSpinUp)) { points.add(new QPoint(x, y + h)); points.add(new QPoint(x + w, y + h)); points.add(new QPoint(x + w / 2, y)); } else { // PE_SpinBoxDown points.add(new QPoint(x, y)); points.add(new QPoint(x + w, y)); points.add(new QPoint(x + w / 2, y + h)); } if (option.state().isSet(QStyle.StateFlag.State_Enabled)) { painter.setPen(option.palette().mid().color()); painter.setBrush(option.palette().buttonText()); } else { painter.setPen(option.palette().buttonText().color()); painter.setBrush(option.palette().mid()); } painter.drawPolygon(points); } else { super.drawPrimitive(element, option, painter, widget); } }Notice that we don't use the widget argument, except to pass it on to the QWindowStyle::drawPrimitive() function. As mentioned earlier, the information about what is to be drawn and how it should be drawn is specified by a
QStyleOption
object, so there is no need to ask the widget. If you need to use the widget argument to obtain additional information, be careful to ensure that it isn't 0 and that it is of the correct type before using it. For example:
if (widget instanceof QSpinBox) { QSpinBox spinBox = (QSpinBox) widget; ... }When implementing a custom style, you cannot assume that the widget is a
QSpinBox
just because the enum value is called PE_IndicatorSpinUp
or PE_IndicatorSpinDown
. The documentation for the Styles example covers this topic in more detail.
Warning: Qt style sheets are currently not supported for custom QStyle subclasses. We plan to address this in some future release.Using a Custom Style
There are several ways of using a custom style in a Qt application. The simplest way is call the QApplication::setStyle()
static function before creating the QApplication
object:
The following code example is written in c++.
#include <QtGui> #include "customstyle.h" int main(int argc, char *argv[]) { QApplication::setStyle(new CustomStyle); QApplication app(argc, argv); QSpinBox spinBox; spinBox.show(); return app.exec(); }You can call
QApplication::setStyle()
at any time, but by calling it before the constructor, you ensure that the user's preference, set using the -style command-line option, is respected. You may want to make your style available for use in other applications, some of which may not be yours and are not available for you to recompile. The Qt Plugin system makes it possible to create styles as plugins. Styles created as plugins are loaded as shared objects at runtime by Qt itself. Please refer to the Qt Plugin documentation for more information on how to go about creating a style plugin.
Compile your plugin and put it into Qt's plugins/styles directory. We now have a pluggable style that Qt can load automatically. To use your new style with existing applications, simply start the application with the following argument:
./myapplication -style customThe application will use the look and feel from the custom style you implemented.
If you create a custom style, you should take special care when drawing asymmetric elements to make sure that they also look correct in a mirrored layout. An easy way to test your styles is to run applications with the -reverse command-line option or to call QApplication::setLayoutDirection()
in your main() function.
Here are some things to keep in mind when making a style work well in a right-to-left environment:
subControlRect()
and subElementRect()
return rectangles in screen coordinatesvisualRect()
, visualPos()
, and visualAlignment()
are helpful functions that will translate from logical to screen representations.alignedRect()
will return a logical rect aligned for the current directionQStyledItemDelegate
, is also used for for calculating bounding rectangles of items, and their sub-elements for the various kind of item data roles
QStyledItemDelegate
supports. See the QStyledItemDelegate
class description to find out which datatypes and roles are supported. You can read more about item data roles in Model/View Programming. When QStyledItemDelegate
paints its items, it draws CE_ItemViewItem
, and calculates their size with CT_ItemViewItem
. Note also that it uses SE_ItemViewItemText
to set the size of editors. When implementing a style to customize drawing of item views, you need to check the implementation of QCommonStyle
(and any other subclasses from which your style inherits). This way, you find out which and how other style elements are painted, and you can then reimplement the painting of elements that should be drawn differently.
We include a small example where we customize the drawing of item backgrounds.
The following code example is written in c++.
switch (element) { case (PE_PanelItemViewItem): { painter->save(); QPoint topLeft = option->rect.topLeft(); QPoint bottomRight = option->rect.topRight(); QLinearGradient backgroundGradient(topLeft, bottomRight); backgroundGradient.setColorAt(0.0, QColor(Qt::yellow).lighter(190)); backgroundGradient.setColorAt(1.0, Qt::white); painter->fillRect(option->rect, QBrush(backgroundGradient)); painter->restore(); break; } default: QWindowsStyle::drawPrimitive(element, option, painter, widget); }The primitive element
PE_PanelItemViewItem
is responsible for painting the background of items, and is called from QCommonStyle
's implementation of CE_ItemViewItem
. To add support for drawing of new datatypes and item data roles, it is necessary to create a custom delegate. But if you only need to support the datatypes implemented by the default delegate, a custom style does not need an accompanying delegate. The QStyledItemDelegate
class description gives more information on custom delegates.
The drawing of item view headers is also done by the style, giving control over size of header items and row and column sizes.
QStyleOption
, QStylePainter
, Styles Example, Implementing Styles and Style Aware Widgets, and QStyledItemDelegate
.
Nested Class Summary | |
---|---|
static class |
QStyle.ComplexControl
This enum describes the available complex controls. |
static class |
QStyle.ContentsType
This enum describes the available contents types. |
static class |
QStyle.ControlElement
This enum represents a control element. |
static class |
QStyle.PixelMetric
This enum describes the various available pixel metrics. |
static class |
QStyle.PrimitiveElement
This enum describes that various primitive elements. |
static class |
QStyle.StandardPixmap
This enum describes the available standard pixmaps. |
static class |
QStyle.State
|
static class |
QStyle.StateFlag
This enum describes flags that are used when drawing primitive elements. |
static class |
QStyle.StyleHint
This enum describes the available style hints. |
static class |
QStyle.SubControl
|
static class |
QStyle.SubElement
This enum represents a sub-area of a widget. |
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9 |
Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal |
Field Summary |
---|
Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
currentSender |
Constructor Summary | |
---|---|
QStyle()
Constructs a style object. |
Method Summary | |
---|---|
static QRect |
alignedRect(Qt.LayoutDirection direction,
Qt.Alignment alignment,
QSize size,
QRect rectangle)
Returns a new rectangle of the specified size that is aligned to the given rectangle according to the specified alignment and direction. |
int |
combinedLayoutSpacing(QSizePolicy.ControlTypes controls1,
QSizePolicy.ControlTypes controls2,
Qt.Orientation orientation)
Returns the spacing that should be used between controls1 and controls2 in a layout. |
int |
combinedLayoutSpacing(QSizePolicy.ControlTypes controls1,
QSizePolicy.ControlTypes controls2,
Qt.Orientation orientation,
QStyleOption option)
Returns the spacing that should be used between controls1 and controls2 in a layout. |
int |
combinedLayoutSpacing(QSizePolicy.ControlTypes controls1,
QSizePolicy.ControlTypes controls2,
Qt.Orientation orientation,
QStyleOption option,
QWidget widget)
Returns the spacing that should be used between controls1 and controls2 in a layout. |
void |
drawComplexControl(QStyle.ComplexControl cc,
QStyleOptionComplex opt,
QPainter p)
Draws the given control using the provided painter with the style options specified by option. |
abstract void |
drawComplexControl(QStyle.ComplexControl cc,
QStyleOptionComplex opt,
QPainter p,
QWidget widget)
Draws the given control using the provided painter with the style options specified by option. |
void |
drawControl(QStyle.ControlElement element,
QStyleOption opt,
QPainter p)
Draws the given element with the provided painter with the style options specified by option. |
abstract void |
drawControl(QStyle.ControlElement element,
QStyleOption opt,
QPainter p,
QWidget w)
Draws the given element with the provided painter with the style options specified by option. |
void |
drawItemPixmap(QPainter painter,
QRect rect,
int alignment,
QPixmap pixmap)
Draws the given pixmap in the specified rectangle, according to the specified alignment, using the provided painter. |
void |
drawItemText(QPainter painter,
QRect rect,
int flags,
QPalette pal,
boolean enabled,
java.lang.String text)
Draws the given text in the specified rectangle using the provided painter and palette. |
void |
drawItemText(QPainter painter,
QRect rect,
int flags,
QPalette pal,
boolean enabled,
java.lang.String text,
QPalette.ColorRole textRole)
Draws the given text in the specified rectangle using the provided painter and palette. |
void |
drawPrimitive(QStyle.PrimitiveElement pe,
QStyleOption opt,
QPainter p)
Draws the given primitive element with the provided painter using the style options specified by option. |
abstract void |
drawPrimitive(QStyle.PrimitiveElement pe,
QStyleOption opt,
QPainter p,
QWidget w)
Draws the given primitive element with the provided painter using the style options specified by option. |
abstract QPixmap |
generatedIconPixmap(QIcon.Mode iconMode,
QPixmap pixmap,
QStyleOption opt)
Returns a copy of the given pixmap, styled to conform to the specified iconMode and taking into account the palette specified by option. |
int |
hitTestComplexControl(QStyle.ComplexControl cc,
QStyleOptionComplex opt,
QPoint pt)
Returns the sub control at the given position in the given complex control (with the style options specified by option). |
abstract int |
hitTestComplexControl(QStyle.ComplexControl cc,
QStyleOptionComplex opt,
QPoint pt,
QWidget widget)
Returns the sub control at the given position in the given complex control (with the style options specified by option). |
QRect |
itemPixmapRect(QRect r,
int flags,
QPixmap pixmap)
Returns the area within the given rectangle in which to draw the specified pixmap according to the defined alignment. |
QRect |
itemTextRect(QFontMetrics fm,
QRect r,
int flags,
boolean enabled,
java.lang.String text)
Returns the area within the given rectangle in which to draw the provided text according to the specified font metrics and alignment. |
int |
layoutSpacing(QSizePolicy.ControlType control1,
QSizePolicy.ControlType control2,
Qt.Orientation orientation)
Returns the spacing that should be used between control1 and control2 in a layout. |
int |
layoutSpacing(QSizePolicy.ControlType control1,
QSizePolicy.ControlType control2,
Qt.Orientation orientation,
QStyleOption option)
Returns the spacing that should be used between control1 and control2 in a layout. |
int |
layoutSpacing(QSizePolicy.ControlType control1,
QSizePolicy.ControlType control2,
Qt.Orientation orientation,
QStyleOption option,
QWidget widget)
Returns the spacing that should be used between control1 and control2 in a layout. |
protected int |
layoutSpacingImplementation(QSizePolicy.ControlType control1,
QSizePolicy.ControlType control2,
Qt.Orientation orientation)
This slot is called by layoutSpacing() to determine the spacing that should be used between control1 and control2 in a layout. |
protected int |
layoutSpacingImplementation(QSizePolicy.ControlType control1,
QSizePolicy.ControlType control2,
Qt.Orientation orientation,
QStyleOption option)
This slot is called by layoutSpacing() to determine the spacing that should be used between control1 and control2 in a layout. |
protected int |
layoutSpacingImplementation(QSizePolicy.ControlType control1,
QSizePolicy.ControlType control2,
Qt.Orientation orientation,
QStyleOption option,
QWidget widget)
This slot is called by layoutSpacing() to determine the spacing that should be used between control1 and control2 in a layout. |
int |
pixelMetric(QStyle.PixelMetric metric)
Returns the value of the given pixel metric. |
int |
pixelMetric(QStyle.PixelMetric metric,
QStyleOption option)
Returns the value of the given pixel metric. |
abstract int |
pixelMetric(QStyle.PixelMetric metric,
QStyleOption option,
QWidget widget)
Returns the value of the given pixel metric. |
void |
polish(QApplication arg__1)
Late initialization of the given application object. |
void |
polish(QPalette arg__1)
Changes the palette according to style specific requirements for color palettes (if any). |
void |
polish(QWidget arg__1)
Initializes the appearance of the given widget. |
QSize |
sizeFromContents(QStyle.ContentsType ct,
QStyleOption opt,
QSize contentsSize)
Returns the size of the element described by the specified option and type, based on the provided contentsSize. |
abstract QSize |
sizeFromContents(QStyle.ContentsType ct,
QStyleOption opt,
QSize contentsSize,
QWidget w)
Returns the size of the element described by the specified option and type, based on the provided contentsSize. |
static int |
sliderPositionFromValue(int min,
int max,
int val,
int space)
Converts the given logicalValue to a pixel position. |
static int |
sliderPositionFromValue(int min,
int max,
int val,
int space,
boolean upsideDown)
Converts the given logicalValue to a pixel position. |
static int |
sliderValueFromPosition(int min,
int max,
int pos,
int space)
Converts the given pixel position to a logical value. |
static int |
sliderValueFromPosition(int min,
int max,
int pos,
int space,
boolean upsideDown)
Converts the given pixel position to a logical value. |
QIcon |
standardIcon(QStyle.StandardPixmap standardIcon)
Returns an icon for the given standardIcon. |
QIcon |
standardIcon(QStyle.StandardPixmap standardIcon,
QStyleOption option)
Returns an icon for the given standardIcon. |
QIcon |
standardIcon(QStyle.StandardPixmap standardIcon,
QStyleOption option,
QWidget widget)
Returns an icon for the given standardIcon. |
protected QIcon |
standardIconImplementation(QStyle.StandardPixmap standardIcon)
Returns an icon for the given standardIcon. |
protected QIcon |
standardIconImplementation(QStyle.StandardPixmap standardIcon,
QStyleOption opt)
Returns an icon for the given standardIcon. |
protected QIcon |
standardIconImplementation(QStyle.StandardPixmap standardIcon,
QStyleOption opt,
QWidget widget)
Returns an icon for the given standardIcon. |
QPalette |
standardPalette()
Returns the style's standard palette. |
int |
styleHint(QStyle.StyleHint stylehint)
Returns an integer representing the specified style hint for the given widget described by the provided style option. |
int |
styleHint(QStyle.StyleHint stylehint,
QStyleOption opt)
Returns an integer representing the specified style hint for the given widget described by the provided style option. |
int |
styleHint(QStyle.StyleHint stylehint,
QStyleOption opt,
QWidget widget)
Returns an integer representing the specified style hint for the given widget described by the provided style option. |
abstract int |
styleHint(QStyle.StyleHint stylehint,
QStyleOption opt,
QWidget widget,
QStyleHintReturn returnData)
Returns an integer representing the specified style hint for the given widget described by the provided style option. |
QRect |
subControlRect(QStyle.ComplexControl cc,
QStyleOptionComplex opt,
int sc)
Returns the rectangle containing the specified subControl of the given complex control (with the style specified by option). |
abstract QRect |
subControlRect(QStyle.ComplexControl cc,
QStyleOptionComplex opt,
int sc,
QWidget widget)
Returns the rectangle containing the specified subControl of the given complex control (with the style specified by option). |
QRect |
subElementRect(QStyle.SubElement subElement,
QStyleOption option)
Returns the sub-area for the given element as described in the provided style option. |
abstract QRect |
subElementRect(QStyle.SubElement subElement,
QStyleOption option,
QWidget widget)
Returns the sub-area for the given element as described in the provided style option. |
void |
unpolish(QApplication arg__1)
Uninitialize the given application. |
void |
unpolish(QWidget arg__1)
Uninitialize the given widget's appearance. |
static Qt.Alignment |
visualAlignment(Qt.LayoutDirection direction,
Qt.Alignment alignment)
Transforms an alignment of Qt::AlignLeft or Qt::AlignRight without Qt::AlignAbsolute into Qt::AlignLeft or Qt::AlignRight with Qt::AlignAbsolute according to the layout direction. |
static Qt.Alignment |
visualAlignment(Qt.LayoutDirection direction,
Qt.AlignmentFlag[] alignment)
|
static QPoint |
visualPos(Qt.LayoutDirection direction,
QRect boundingRect,
QPoint logicalPos)
Returns the given logicalPosition converted to screen coordinates based on the specified direction. |
static QRect |
visualRect(Qt.LayoutDirection direction,
QRect boundingRect,
QRect logicalRect)
Returns the given logicalRectangle converted to screen coordinates based on the specified direction. |
Methods inherited from class com.trolltech.qt.core.QObject |
---|
childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread |
Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
__qt_signalInitialization |
Methods inherited from class java.lang.Object |
---|
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Constructor Detail |
---|
public QStyle()
Method Detail |
---|
protected final int layoutSpacingImplementation(QSizePolicy.ControlType control1, QSizePolicy.ControlType control2, Qt.Orientation orientation, QStyleOption option)
layoutSpacing()
to determine the spacing that should be used between control1 and control2 in a layout. orientation specifies whether the controls are laid out side by side or stacked vertically. The option parameter can be used to pass extra information about the parent widget. The widget parameter is optional and can also be used if option is 0. If you want to provide custom layout spacings in a QStyle subclass, implement a slot called layoutSpacingImplementation()
in your subclass. Be aware that this slot will only be called if PM_LayoutHorizontalSpacing
or PM_LayoutVerticalSpacing
returns a negative value.
The default implementation returns -1.
layoutSpacing()
, and combinedLayoutSpacing()
.
protected final int layoutSpacingImplementation(QSizePolicy.ControlType control1, QSizePolicy.ControlType control2, Qt.Orientation orientation)
layoutSpacing()
to determine the spacing that should be used between control1 and control2 in a layout. orientation specifies whether the controls are laid out side by side or stacked vertically. The option parameter can be used to pass extra information about the parent widget. The widget parameter is optional and can also be used if option is 0. If you want to provide custom layout spacings in a QStyle subclass, implement a slot called layoutSpacingImplementation()
in your subclass. Be aware that this slot will only be called if PM_LayoutHorizontalSpacing
or PM_LayoutVerticalSpacing
returns a negative value.
The default implementation returns -1.
layoutSpacing()
, and combinedLayoutSpacing()
.
protected int layoutSpacingImplementation(QSizePolicy.ControlType control1, QSizePolicy.ControlType control2, Qt.Orientation orientation, QStyleOption option, QWidget widget)
layoutSpacing()
to determine the spacing that should be used between control1 and control2 in a layout. orientation specifies whether the controls are laid out side by side or stacked vertically. The option parameter can be used to pass extra information about the parent widget. The widget parameter is optional and can also be used if option is 0. If you want to provide custom layout spacings in a QStyle subclass, implement a slot called layoutSpacingImplementation()
in your subclass. Be aware that this slot will only be called if PM_LayoutHorizontalSpacing
or PM_LayoutVerticalSpacing
returns a negative value.
The default implementation returns -1.
layoutSpacing()
, and combinedLayoutSpacing()
.
public final QIcon standardIcon(QStyle.StandardPixmap standardIcon, QStyleOption option)
The standardIcon is a standard pixmap which can follow some existing GUI style or guideline. The option argument can be used to pass extra information required when defining the appropriate icon. The widget argument is optional and can also be used to aid the determination of the icon.
Warning: Because of binary compatibility constraints, this function is not virtual. If you want to provide your own icons in a QStyle subclass, reimplement the standardIconImplementation()
slot in your subclass instead. The standardIcon()
function will dynamically detect the slot and call it.
standardIconImplementation()
, and standardPixmap().
public final QIcon standardIcon(QStyle.StandardPixmap standardIcon)
The standardIcon is a standard pixmap which can follow some existing GUI style or guideline. The option argument can be used to pass extra information required when defining the appropriate icon. The widget argument is optional and can also be used to aid the determination of the icon.
Warning: Because of binary compatibility constraints, this function is not virtual. If you want to provide your own icons in a QStyle subclass, reimplement the standardIconImplementation()
slot in your subclass instead. The standardIcon()
function will dynamically detect the slot and call it.
standardIconImplementation()
, and standardPixmap().
public final QIcon standardIcon(QStyle.StandardPixmap standardIcon, QStyleOption option, QWidget widget)
The standardIcon is a standard pixmap which can follow some existing GUI style or guideline. The option argument can be used to pass extra information required when defining the appropriate icon. The widget argument is optional and can also be used to aid the determination of the icon.
Warning: Because of binary compatibility constraints, this function is not virtual. If you want to provide your own icons in a QStyle subclass, reimplement the standardIconImplementation()
slot in your subclass instead. The standardIcon()
function will dynamically detect the slot and call it.
standardIconImplementation()
, and standardPixmap().
protected final QIcon standardIconImplementation(QStyle.StandardPixmap standardIcon, QStyleOption opt)
Reimplement this slot to provide your own icons in a QStyle subclass; because of binary compatibility constraints, the standardIcon()
function (introduced in Qt 4.1) is not virtual. Instead, standardIcon()
will dynamically detect and call this slot. The default implementation simply calls the standardPixmap() function with the given parameters.
The standardIcon is a standard pixmap which can follow some existing GUI style or guideline. The option argument can be used to pass extra information required when defining the appropriate icon. The widget argument is optional and can also be used to aid the determination of the icon.
standardIcon()
.
protected final QIcon standardIconImplementation(QStyle.StandardPixmap standardIcon)
Reimplement this slot to provide your own icons in a QStyle subclass; because of binary compatibility constraints, the standardIcon()
function (introduced in Qt 4.1) is not virtual. Instead, standardIcon()
will dynamically detect and call this slot. The default implementation simply calls the standardPixmap() function with the given parameters.
The standardIcon is a standard pixmap which can follow some existing GUI style or guideline. The option argument can be used to pass extra information required when defining the appropriate icon. The widget argument is optional and can also be used to aid the determination of the icon.
standardIcon()
.
protected QIcon standardIconImplementation(QStyle.StandardPixmap standardIcon, QStyleOption opt, QWidget widget)
Reimplement this slot to provide your own icons in a QStyle subclass; because of binary compatibility constraints, the standardIcon()
function (introduced in Qt 4.1) is not virtual. Instead, standardIcon()
will dynamically detect and call this slot. The default implementation simply calls the standardPixmap() function with the given parameters.
The standardIcon is a standard pixmap which can follow some existing GUI style or guideline. The option argument can be used to pass extra information required when defining the appropriate icon. The widget argument is optional and can also be used to aid the determination of the icon.
standardIcon()
.
public final void drawComplexControl(QStyle.ComplexControl cc, QStyleOptionComplex opt, QPainter p)
The widget argument is optional and can be used as aid in drawing the control.
The option parameter is a pointer to a QStyleOptionComplex
object that can be cast to the correct subclass using the qstyleoption_cast() function. Note that the rect member of the specified option must be in logical coordinates. Reimplementations of this function should use visualRect()
to change the logical coordinates into screen coordinates before calling the drawPrimitive()
or drawControl()
function.
The table below is listing the complex control elements and their associated style option subclass. The style options contain all the parameters required to draw the controls, including QStyleOption::state which holds the style flags
that are used when drawing. The table also describes which flags that are set when casting the given option to the appropriate subclass.
QStyleOptionComplex Subclass | |||
---|---|---|---|
CC_SpinBox | QStyleOptionSpinBox | State_Enabled | Set if the spin box is enabled. |
State_HasFocus | Set if the spin box has input focus. | ||
CC_ComboBox | QStyleOptionComboBox | State_Enabled | Set if the combobox is enabled. |
State_HasFocus | Set if the combobox has input focus. | ||
CC_ScrollBar | QStyleOptionSlider | State_Enabled | Set if the scroll bar is enabled. |
State_HasFocus | Set if the scroll bar has input focus. | ||
CC_Slider | QStyleOptionSlider | State_Enabled | Set if the slider is enabled. |
State_HasFocus | Set if the slider has input focus. | ||
CC_Dial | QStyleOptionSlider | State_Enabled | Set if the dial is enabled. |
State_HasFocus | Set if the dial has input focus. | ||
CC_ToolButton | QStyleOptionToolButton | State_Enabled | Set if the tool button is enabled. |
State_HasFocus | Set if the tool button has input focus. | ||
State_DownArrow | Set if the tool button is down (i.e., a mouse button or the space bar is pressed). | ||
State_On | Set if the tool button is a toggle button and is toggled on. | ||
State_AutoRaise | Set if the tool button has auto-raise enabled. | ||
State_Raised | Set if the button is not down, not on, and doesn't contain the mouse when auto-raise is enabled. | ||
CC_TitleBar | QStyleOptionTitleBar | State_Enabled | Set if the title bar is enabled. |
CC_Q3ListView | QStyleOptionQ3ListView | State_Enabled | Set if the list view is enabled. |
drawPrimitive()
, and drawControl()
.
public abstract void drawComplexControl(QStyle.ComplexControl cc, QStyleOptionComplex opt, QPainter p, QWidget widget)
The widget argument is optional and can be used as aid in drawing the control.
The option parameter is a pointer to a QStyleOptionComplex
object that can be cast to the correct subclass using the qstyleoption_cast() function. Note that the rect member of the specified option must be in logical coordinates. Reimplementations of this function should use visualRect()
to change the logical coordinates into screen coordinates before calling the drawPrimitive()
or drawControl()
function.
The table below is listing the complex control elements and their associated style option subclass. The style options contain all the parameters required to draw the controls, including QStyleOption::state which holds the style flags
that are used when drawing. The table also describes which flags that are set when casting the given option to the appropriate subclass.
QStyleOptionComplex Subclass | |||
---|---|---|---|
CC_SpinBox | QStyleOptionSpinBox | State_Enabled | Set if the spin box is enabled. |
State_HasFocus | Set if the spin box has input focus. | ||
CC_ComboBox | QStyleOptionComboBox | State_Enabled | Set if the combobox is enabled. |
State_HasFocus | Set if the combobox has input focus. | ||
CC_ScrollBar | QStyleOptionSlider | State_Enabled | Set if the scroll bar is enabled. |
State_HasFocus | Set if the scroll bar has input focus. | ||
CC_Slider | QStyleOptionSlider | State_Enabled | Set if the slider is enabled. |
State_HasFocus | Set if the slider has input focus. | ||
CC_Dial | QStyleOptionSlider | State_Enabled | Set if the dial is enabled. |
State_HasFocus | Set if the dial has input focus. | ||
CC_ToolButton | QStyleOptionToolButton | State_Enabled | Set if the tool button is enabled. |
State_HasFocus | Set if the tool button has input focus. | ||
State_DownArrow | Set if the tool button is down (i.e., a mouse button or the space bar is pressed). | ||
State_On | Set if the tool button is a toggle button and is toggled on. | ||
State_AutoRaise | Set if the tool button has auto-raise enabled. | ||
State_Raised | Set if the button is not down, not on, and doesn't contain the mouse when auto-raise is enabled. | ||
CC_TitleBar | QStyleOptionTitleBar | State_Enabled | Set if the title bar is enabled. |
CC_Q3ListView | QStyleOptionQ3ListView | State_Enabled | Set if the list view is enabled. |
drawPrimitive()
, and drawControl()
.
public final void drawControl(QStyle.ControlElement element, QStyleOption opt, QPainter p)
The widget argument is optional and can be used as aid in drawing the control. The option parameter is a pointer to a QStyleOption
object that can be cast to the correct subclass using the qstyleoption_cast() function.
The table below is listing the control elements and their associated style option subclass. The style options contain all the parameters required to draw the controls, including QStyleOption::state which holds the style flags that are used when drawing. The table also describes which flags that are set when casting the given option to the appropriate subclass.
Note that if a control element is not listed here, it is because it uses a plain QStyleOption
object.
QStyleOption Subclass | |||
---|---|---|---|
CE_MenuItem , CE_MenuBarItem | QStyleOptionMenuItem | State_Selected | The menu item is currently selected item. |
State_Enabled | The item is enabled. | ||
State_DownArrow | Indicates that a scroll down arrow should be drawn. | ||
State_UpArrow | Indicates that a scroll up arrow should be drawn | ||
State_HasFocus | Set if the menu bar has input focus. | ||
CE_PushButton , CE_PushButtonBevel , CE_PushButtonLabel | QStyleOptionButton | State_Enabled | Set if the button is enabled. |
State_HasFocus | Set if the button has input focus. | ||
State_Raised | Set if the button is not down, not on and not flat. | ||
State_On | Set if the button is a toggle button and is toggled on. | ||
State_Sunken | Set if the button is down (i.e., the mouse button or the space bar is pressed on the button). | ||
CE_RadioButton , CE_RadioButtonLabel , CE_CheckBox , CE_CheckBoxLabel | QStyleOptionButton | State_Enabled | Set if the button is enabled. |
State_HasFocus | Set if the button has input focus. | ||
State_On | Set if the button is checked. | ||
State_Off | Set if the button is not checked. | ||
State_NoChange | Set if the button is in the NoChange state. | ||
State_Sunken | Set if the button is down (i.e., the mouse button or the space bar is pressed on the button). | ||
CE_ProgressBarContents , CE_ProgressBarLabel , CE_ProgressBarGroove | QStyleOptionProgressBar | State_Enabled | Set if the progress bar is enabled. |
State_HasFocus | Set if the progress bar has input focus. | ||
CE_Header , CE_HeaderSection , CE_HeaderLabel | QStyleOptionHeader | ||
CE_TabBarTab , CE_TabBarTabShape , CE_TabBarTabLabel | QStyleOptionTab | State_Enabled | Set if the tab bar is enabled. |
State_Selected | The tab bar is the currently selected tab bar. | ||
State_HasFocus | Set if the tab bar tab has input focus. | ||
CE_ToolButtonLabel | QStyleOptionToolButton | State_Enabled | Set if the tool button is enabled. |
State_HasFocus | Set if the tool button has input focus. | ||
State_Sunken | Set if the tool button is down (i.e., a mouse button or the space bar is pressed). | ||
State_On | Set if the tool button is a toggle button and is toggled on. | ||
State_AutoRaise | Set if the tool button has auto-raise enabled. | ||
State_MouseOver | Set if the mouse pointer is over the tool button. | ||
State_Raised | Set if the button is not down and is not on. | ||
CE_ToolBoxTab | QStyleOptionToolBox | State_Selected | The tab is the currently selected tab. |
CE_HeaderSection | QStyleOptionHeader | State_Sunken | Indicates that the section is pressed. |
State_UpArrow | Indicates that the sort indicator should be pointing up. | ||
State_DownArrow | Indicates that the sort indicator should be pointing down. |
drawPrimitive()
, and drawComplexControl()
.
public abstract void drawControl(QStyle.ControlElement element, QStyleOption opt, QPainter p, QWidget w)
The widget argument is optional and can be used as aid in drawing the control. The option parameter is a pointer to a QStyleOption
object that can be cast to the correct subclass using the qstyleoption_cast() function.
The table below is listing the control elements and their associated style option subclass. The style options contain all the parameters required to draw the controls, including QStyleOption::state which holds the style flags that are used when drawing. The table also describes which flags that are set when casting the given option to the appropriate subclass.
Note that if a control element is not listed here, it is because it uses a plain QStyleOption
object.
QStyleOption Subclass | |||
---|---|---|---|
CE_MenuItem , CE_MenuBarItem | QStyleOptionMenuItem | State_Selected | The menu item is currently selected item. |
State_Enabled | The item is enabled. | ||
State_DownArrow | Indicates that a scroll down arrow should be drawn. | ||
State_UpArrow | Indicates that a scroll up arrow should be drawn | ||
State_HasFocus | Set if the menu bar has input focus. | ||
CE_PushButton , CE_PushButtonBevel , CE_PushButtonLabel | QStyleOptionButton | State_Enabled | Set if the button is enabled. |
State_HasFocus | Set if the button has input focus. | ||
State_Raised | Set if the button is not down, not on and not flat. | ||
State_On | Set if the button is a toggle button and is toggled on. | ||
State_Sunken | Set if the button is down (i.e., the mouse button or the space bar is pressed on the button). | ||
CE_RadioButton , CE_RadioButtonLabel , CE_CheckBox , CE_CheckBoxLabel | QStyleOptionButton | State_Enabled | Set if the button is enabled. |
State_HasFocus | Set if the button has input focus. | ||
State_On | Set if the button is checked. | ||
State_Off | Set if the button is not checked. | ||
State_NoChange | Set if the button is in the NoChange state. | ||
State_Sunken | Set if the button is down (i.e., the mouse button or the space bar is pressed on the button). | ||
CE_ProgressBarContents , CE_ProgressBarLabel , CE_ProgressBarGroove | QStyleOptionProgressBar | State_Enabled | Set if the progress bar is enabled. |
State_HasFocus | Set if the progress bar has input focus. | ||
CE_Header , CE_HeaderSection , CE_HeaderLabel | QStyleOptionHeader | ||
CE_TabBarTab , CE_TabBarTabShape , CE_TabBarTabLabel | QStyleOptionTab | State_Enabled | Set if the tab bar is enabled. |
State_Selected | The tab bar is the currently selected tab bar. | ||
State_HasFocus | Set if the tab bar tab has input focus. | ||
CE_ToolButtonLabel | QStyleOptionToolButton | State_Enabled | Set if the tool button is enabled. |
State_HasFocus | Set if the tool button has input focus. | ||
State_Sunken | Set if the tool button is down (i.e., a mouse button or the space bar is pressed). | ||
State_On | Set if the tool button is a toggle button and is toggled on. | ||
State_AutoRaise | Set if the tool button has auto-raise enabled. | ||
State_MouseOver | Set if the mouse pointer is over the tool button. | ||
State_Raised | Set if the button is not down and is not on. | ||
CE_ToolBoxTab | QStyleOptionToolBox | State_Selected | The tab is the currently selected tab. |
CE_HeaderSection | QStyleOptionHeader | State_Sunken | Indicates that the section is pressed. |
State_UpArrow | Indicates that the sort indicator should be pointing up. | ||
State_DownArrow | Indicates that the sort indicator should be pointing down. |
drawPrimitive()
, and drawComplexControl()
.
public void drawItemPixmap(QPainter painter, QRect rect, int alignment, QPixmap pixmap)
drawItemText()
.
public final void drawItemText(QPainter painter, QRect rect, int flags, QPalette pal, boolean enabled, java.lang.String text)
The text is drawn using the painter's pen, and aligned and wrapped according to the specified alignment. If an explicit textRole is specified, the text is drawn using the palette's color for the given role. The enabled parameter indicates whether or not the item is enabled; when reimplementing this function, the enabled parameter should influence how the item is drawn.
drawItemPixmap()
.
public void drawItemText(QPainter painter, QRect rect, int flags, QPalette pal, boolean enabled, java.lang.String text, QPalette.ColorRole textRole)
The text is drawn using the painter's pen, and aligned and wrapped according to the specified alignment. If an explicit textRole is specified, the text is drawn using the palette's color for the given role. The enabled parameter indicates whether or not the item is enabled; when reimplementing this function, the enabled parameter should influence how the item is drawn.
drawItemPixmap()
.
public final void drawPrimitive(QStyle.PrimitiveElement pe, QStyleOption opt, QPainter p)
The widget argument is optional and may contain a widget that may aid in drawing the primitive element.
The table below is listing the primitive elements and their associated style option subclasses. The style options contain all the parameters required to draw the elements, including QStyleOption::state which holds the style flags that are used when drawing. The table also describes which flags that are set when casting the given option to the appropriate subclass.
Note that if a primitive element is not listed here, it is because it uses a plain QStyleOption
object.
QStyleOption Subclass | |||
---|---|---|---|
PE_FrameFocusRect | QStyleOptionFocusRect | State_FocusAtBorder | Whether the focus is is at the border or inside the widget. |
PE_IndicatorCheckBox | QStyleOptionButton | State_NoChange | Indicates a "tri-state" checkbox. |
State_On | Indicates the indicator is checked. | ||
PE_IndicatorRadioButton | QStyleOptionButton | State_On | Indicates that a radio button is selected. |
PE_Q3CheckListExclusiveIndicator , PE_Q3CheckListIndicator | QStyleOptionQ3ListView | State_On | Indicates whether or not the controller is selected. |
State_NoChange | Indicates a "tri-state" controller. | ||
State_Enabled | Indicates the controller is enabled. | ||
PE_IndicatorBranch | QStyleOption | State_Children | Indicates that the control for expanding the tree to show child items, should be drawn. |
State_Item | Indicates that a horizontal branch (to show a child item), should be drawn. | ||
State_Open | Indicates that the tree branch is expanded. | ||
State_Sibling | Indicates that a vertical line (to show a sibling item), should be drawn. | ||
PE_IndicatorHeaderArrow | QStyleOptionHeader | State_UpArrow | Indicates that the arrow should be drawn up; otherwise it should be down. |
PE_FrameGroupBox , PE_Frame , PE_FrameLineEdit , PE_FrameMenu , PE_FrameDockWidget , PE_FrameWindow | QStyleOptionFrame | State_Sunken | Indicates that the Frame should be sunken. |
PE_IndicatorToolBarHandle | QStyleOption | State_Horizontal | Indicates that the window handle is horizontal instead of vertical. |
PE_Q3DockWindowSeparator | QStyleOption | State_Horizontal | Indicates that the separator is horizontal instead of vertical. |
PE_IndicatorSpinPlus , PE_IndicatorSpinMinus , PE_IndicatorSpinUp , PE_IndicatorSpinDown , | QStyleOptionSpinBox | State_Sunken | Indicates that the button is pressed. |
PE_PanelButtonCommand | QStyleOptionButton | State_Enabled | Set if the button is enabled. |
State_HasFocus | Set if the button has input focus. | ||
State_Raised | Set if the button is not down, not on and not flat. | ||
State_On | Set if the button is a toggle button and is toggled on. | ||
State_Sunken | Set if the button is down (i.e., the mouse button or the space bar is pressed on the button). |
drawComplexControl()
, and drawControl()
.
public abstract void drawPrimitive(QStyle.PrimitiveElement pe, QStyleOption opt, QPainter p, QWidget w)
The widget argument is optional and may contain a widget that may aid in drawing the primitive element.
The table below is listing the primitive elements and their associated style option subclasses. The style options contain all the parameters required to draw the elements, including QStyleOption::state which holds the style flags that are used when drawing. The table also describes which flags that are set when casting the given option to the appropriate subclass.
Note that if a primitive element is not listed here, it is because it uses a plain QStyleOption
object.
QStyleOption Subclass | |||
---|---|---|---|
PE_FrameFocusRect | QStyleOptionFocusRect | State_FocusAtBorder | Whether the focus is is at the border or inside the widget. |
PE_IndicatorCheckBox | QStyleOptionButton | State_NoChange | Indicates a "tri-state" checkbox. |
State_On | Indicates the indicator is checked. | ||
PE_IndicatorRadioButton | QStyleOptionButton | State_On | Indicates that a radio button is selected. |
PE_Q3CheckListExclusiveIndicator , PE_Q3CheckListIndicator | QStyleOptionQ3ListView | State_On | Indicates whether or not the controller is selected. |
State_NoChange | Indicates a "tri-state" controller. | ||
State_Enabled | Indicates the controller is enabled. | ||
PE_IndicatorBranch | QStyleOption | State_Children | Indicates that the control for expanding the tree to show child items, should be drawn. |
State_Item | Indicates that a horizontal branch (to show a child item), should be drawn. | ||
State_Open | Indicates that the tree branch is expanded. | ||
State_Sibling | Indicates that a vertical line (to show a sibling item), should be drawn. | ||
PE_IndicatorHeaderArrow | QStyleOptionHeader | State_UpArrow | Indicates that the arrow should be drawn up; otherwise it should be down. |
PE_FrameGroupBox , PE_Frame , PE_FrameLineEdit , PE_FrameMenu , PE_FrameDockWidget , PE_FrameWindow | QStyleOptionFrame | State_Sunken | Indicates that the Frame should be sunken. |
PE_IndicatorToolBarHandle | QStyleOption | State_Horizontal | Indicates that the window handle is horizontal instead of vertical. |
PE_Q3DockWindowSeparator | QStyleOption | State_Horizontal | Indicates that the separator is horizontal instead of vertical. |
PE_IndicatorSpinPlus , PE_IndicatorSpinMinus , PE_IndicatorSpinUp , PE_IndicatorSpinDown , | QStyleOptionSpinBox | State_Sunken | Indicates that the button is pressed. |
PE_PanelButtonCommand | QStyleOptionButton | State_Enabled | Set if the button is enabled. |
State_HasFocus | Set if the button has input focus. | ||
State_Raised | Set if the button is not down, not on and not flat. | ||
State_On | Set if the button is a toggle button and is toggled on. | ||
State_Sunken | Set if the button is down (i.e., the mouse button or the space bar is pressed on the button). |
drawComplexControl()
, and drawControl()
.
public abstract QPixmap generatedIconPixmap(QIcon.Mode iconMode, QPixmap pixmap, QStyleOption opt)
The option parameter can pass extra information, but it must contain a palette.
Note that not all pixmaps will conform, in which case the returned pixmap is a plain copy.
QIcon
.
public final int hitTestComplexControl(QStyle.ComplexControl cc, QStyleOptionComplex opt, QPoint pt)
Note that the position is expressed in screen coordinates.
The option argument is a pointer to a QStyleOptionComplex
object (or one of its subclasses). The object can be cast to the appropriate type using the qstyleoption_cast() function. See drawComplexControl()
for details. The widget argument is optional and can contain additional information for the function.
drawComplexControl()
, and subControlRect()
.
public abstract int hitTestComplexControl(QStyle.ComplexControl cc, QStyleOptionComplex opt, QPoint pt, QWidget widget)
Note that the position is expressed in screen coordinates.
The option argument is a pointer to a QStyleOptionComplex
object (or one of its subclasses). The object can be cast to the appropriate type using the qstyleoption_cast() function. See drawComplexControl()
for details. The widget argument is optional and can contain additional information for the function.
drawComplexControl()
, and subControlRect()
.
public QRect itemPixmapRect(QRect r, int flags, QPixmap pixmap)
public QRect itemTextRect(QFontMetrics fm, QRect r, int flags, boolean enabled, java.lang.String text)
If the given rectangle is larger than the area needed to render the text, the rectangle that is returned will be offset within rectangle according to the specified alignment. For example, if alignment is Qt::AlignCenter
, the returned rectangle will be centered within rectangle. If the given rectangle is smaller than the area needed, the returned rectangle will be the smallest rectangle large enough to render the text.
public final int pixelMetric(QStyle.PixelMetric metric, QStyleOption option)
The specified option and widget can be used for calculating the metric. In general, the widget argument is not used. The option can be cast to the appropriate type using the qstyleoption_cast() function. Note that the option may be zero even for PixelMetrics that can make use of it. See the table below for the appropriate option casts:
public final int pixelMetric(QStyle.PixelMetric metric)
The specified option and widget can be used for calculating the metric. In general, the widget argument is not used. The option can be cast to the appropriate type using the qstyleoption_cast() function. Note that the option may be zero even for PixelMetrics that can make use of it. See the table below for the appropriate option casts:
public abstract int pixelMetric(QStyle.PixelMetric metric, QStyleOption option, QWidget widget)
The specified option and widget can be used for calculating the metric. In general, the widget argument is not used. The option can be cast to the appropriate type using the qstyleoption_cast() function. Note that the option may be zero even for PixelMetrics that can make use of it. See the table below for the appropriate option casts:
public void polish(QApplication arg__1)
public void polish(QPalette arg__1)
QPalette
, and QApplication::setPalette()
.
public void polish(QWidget arg__1)
This function is called for every widget at some point after it has been fully created but just before it is shown for the very first time.
Note that the default implementation does nothing. Reasonable actions in this function might be to call the QWidget::setBackgroundMode() function for the widget. Do not use the function to set, for example, the geometry; reimplementing this function do provide a back-door through which the appearance of a widget can be changed, but with Qt 4.0's style engine there is rarely necessary to implement this function; reimplement the drawItemPixmap()
, drawItemText()
, drawPrimitive()
, etc. instead.
The QWidget::inherits() function may provide enough information to allow class-specific customizations. But because new QStyle subclasses are expected to work reasonably with all current and future widgets, limited use of hard-coded customization is recommended.
unpolish()
.
public final QSize sizeFromContents(QStyle.ContentsType ct, QStyleOption opt, QSize contentsSize)
The option argument is a pointer to a QStyleOption
or one of its subclasses. The option can be cast to the appropriate type using the qstyleoption_cast() function. The widget is an optional argument and can contain extra information used for calculating the size.
See the table below for the appropriate option casts:
ContentsType
, and QStyleOption
.
public abstract QSize sizeFromContents(QStyle.ContentsType ct, QStyleOption opt, QSize contentsSize, QWidget w)
The option argument is a pointer to a QStyleOption
or one of its subclasses. The option can be cast to the appropriate type using the qstyleoption_cast() function. The widget is an optional argument and can contain extra information used for calculating the size.
See the table below for the appropriate option casts:
ContentsType
, and QStyleOption
.
public QPalette standardPalette()
Note that on systems that support system colors, the style's standard palette is not used. In particular, the Windows XP, Vista, and Mac styles do not use the standard palette, but make use of native theme engines. With these styles, you should not set the palette with QApplication::setStandardPalette().
public final int styleHint(QStyle.StyleHint stylehint, QStyleOption opt, QWidget widget)
Note that currently, the returnData and widget parameters are not used; they are provided for future enhancement. In addition, the option parameter is used only in case of the SH_ComboBox_Popup
, SH_ComboBox_LayoutDirection
, and SH_GroupBox_TextLabelColor
style hints.
public final int styleHint(QStyle.StyleHint stylehint, QStyleOption opt)
Note that currently, the returnData and widget parameters are not used; they are provided for future enhancement. In addition, the option parameter is used only in case of the SH_ComboBox_Popup
, SH_ComboBox_LayoutDirection
, and SH_GroupBox_TextLabelColor
style hints.
public final int styleHint(QStyle.StyleHint stylehint)
Note that currently, the returnData and widget parameters are not used; they are provided for future enhancement. In addition, the option parameter is used only in case of the SH_ComboBox_Popup
, SH_ComboBox_LayoutDirection
, and SH_GroupBox_TextLabelColor
style hints.
public abstract int styleHint(QStyle.StyleHint stylehint, QStyleOption opt, QWidget widget, QStyleHintReturn returnData)
Note that currently, the returnData and widget parameters are not used; they are provided for future enhancement. In addition, the option parameter is used only in case of the SH_ComboBox_Popup
, SH_ComboBox_LayoutDirection
, and SH_GroupBox_TextLabelColor
style hints.
public final QRect subControlRect(QStyle.ComplexControl cc, QStyleOptionComplex opt, int sc)
The option argument is a pointer to QStyleOptionComplex
or one of its subclasses, and can be cast to the appropriate type using the qstyleoption_cast() function. See drawComplexControl()
for details. The widget is optional and can contain additional information for the function.
drawComplexControl()
.
public abstract QRect subControlRect(QStyle.ComplexControl cc, QStyleOptionComplex opt, int sc, QWidget widget)
The option argument is a pointer to QStyleOptionComplex
or one of its subclasses, and can be cast to the appropriate type using the qstyleoption_cast() function. See drawComplexControl()
for details. The widget is optional and can contain additional information for the function.
drawComplexControl()
.
public final QRect subElementRect(QStyle.SubElement subElement, QStyleOption option)
The widget argument is optional and can be used to aid determining the area. The QStyleOption
object can be cast to the appropriate type using the qstyleoption_cast() function. See the table below for the appropriate option casts:
public abstract QRect subElementRect(QStyle.SubElement subElement, QStyleOption option, QWidget widget)
The widget argument is optional and can be used to aid determining the area. The QStyleOption
object can be cast to the appropriate type using the qstyleoption_cast() function. See the table below for the appropriate option casts:
public void unpolish(QApplication arg__1)
public void unpolish(QWidget arg__1)
This function is the counterpart to polish()
. It is called for every polished widget whenever the style is dynamically changed; the former style has to unpolish its settings before the new style can polish them again.
Note that unpolish()
will only be called if the widget is destroyed. This can cause problems in some cases, e.g, if you remove a widget from the UI, cache it, and then reinsert it after the style has changed; some of Qt's classes cache their widgets.
polish()
.
public static QRect alignedRect(Qt.LayoutDirection direction, Qt.Alignment alignment, QSize size, QRect rectangle)
public static int sliderPositionFromValue(int min, int max, int val, int space)
This function can handle the entire integer range without overflow, providing that span is less than 4096.
By default, this function assumes that the maximum value is on the right for horizontal items and on the bottom for vertical items. Set the upsideDown parameter to true to reverse this behavior.
sliderValueFromPosition()
.
public static int sliderPositionFromValue(int min, int max, int val, int space, boolean upsideDown)
This function can handle the entire integer range without overflow, providing that span is less than 4096.
By default, this function assumes that the maximum value is on the right for horizontal items and on the bottom for vertical items. Set the upsideDown parameter to true to reverse this behavior.
sliderValueFromPosition()
.
public static int sliderValueFromPosition(int min, int max, int pos, int space)
This function can handle the entire integer range without overflow.
By default, this function assumes that the maximum value is on the right for horizontal items and on the bottom for vertical items. Set the upsideDown parameter to true to reverse this behavior.
sliderPositionFromValue()
.
public static int sliderValueFromPosition(int min, int max, int pos, int space, boolean upsideDown)
This function can handle the entire integer range without overflow.
By default, this function assumes that the maximum value is on the right for horizontal items and on the bottom for vertical items. Set the upsideDown parameter to true to reverse this behavior.
sliderPositionFromValue()
.
public static Qt.Alignment visualAlignment(Qt.LayoutDirection direction, Qt.AlignmentFlag[] alignment)
public static Qt.Alignment visualAlignment(Qt.LayoutDirection direction, Qt.Alignment alignment)
Qt::AlignLeft
or Qt::AlignRight
without Qt::AlignAbsolute
into Qt::AlignLeft
or Qt::AlignRight
with Qt::AlignAbsolute
according to the layout direction. The other alignment flags are left untouched. If no horizontal alignment was specified, the function returns the default alignment for the given layout direction.
public static QPoint visualPos(Qt.LayoutDirection direction, QRect boundingRect, QPoint logicalPos)
QWidget::layoutDirection
.
public static QRect visualRect(Qt.LayoutDirection direction, QRect boundingRect, QRect logicalRect)
This function is provided to support right-to-left desktops, and is typically used in implementations of the subControlRect()
function.
QWidget::layoutDirection
.
public final int combinedLayoutSpacing(QSizePolicy.ControlTypes controls1, QSizePolicy.ControlTypes controls2, Qt.Orientation orientation, QStyleOption option, QWidget widget)
controls1 and controls2 are OR-combination of zero or more control types.
This function is called by the layout system. It is used only if PM_LayoutHorizontalSpacing
or PM_LayoutVerticalSpacing
returns a negative value.
layoutSpacing()
, and layoutSpacingImplementation()
.
public final int combinedLayoutSpacing(QSizePolicy.ControlTypes controls1, QSizePolicy.ControlTypes controls2, Qt.Orientation orientation, QStyleOption option)
controls1 and controls2 are OR-combination of zero or more control types.
This function is called by the layout system. It is used only if PM_LayoutHorizontalSpacing
or PM_LayoutVerticalSpacing
returns a negative value.
layoutSpacing()
, and layoutSpacingImplementation()
.
public final int combinedLayoutSpacing(QSizePolicy.ControlTypes controls1, QSizePolicy.ControlTypes controls2, Qt.Orientation orientation)
controls1 and controls2 are OR-combination of zero or more control types.
This function is called by the layout system. It is used only if PM_LayoutHorizontalSpacing
or PM_LayoutVerticalSpacing
returns a negative value.
layoutSpacing()
, and layoutSpacingImplementation()
.
public final int layoutSpacing(QSizePolicy.ControlType control1, QSizePolicy.ControlType control2, Qt.Orientation orientation, QStyleOption option, QWidget widget)
This function is called by the layout system. It is used only if PM_LayoutHorizontalSpacing
or PM_LayoutVerticalSpacing
returns a negative value.
For binary compatibility reasons, this function is not virtual. If you want to specify custom layout spacings in a QStyle subclass, implement a slot called layoutSpacingImplementation()
. QStyle will discover the slot at run-time (using Qt's meta-object system) and direct all calls to layoutSpacing()
to layoutSpacingImplementation()
.
combinedLayoutSpacing()
, and layoutSpacingImplementation()
.
public final int layoutSpacing(QSizePolicy.ControlType control1, QSizePolicy.ControlType control2, Qt.Orientation orientation, QStyleOption option)
This function is called by the layout system. It is used only if PM_LayoutHorizontalSpacing
or PM_LayoutVerticalSpacing
returns a negative value.
For binary compatibility reasons, this function is not virtual. If you want to specify custom layout spacings in a QStyle subclass, implement a slot called layoutSpacingImplementation()
. QStyle will discover the slot at run-time (using Qt's meta-object system) and direct all calls to layoutSpacing()
to layoutSpacingImplementation()
.
combinedLayoutSpacing()
, and layoutSpacingImplementation()
.
public final int layoutSpacing(QSizePolicy.ControlType control1, QSizePolicy.ControlType control2, Qt.Orientation orientation)
This function is called by the layout system. It is used only if PM_LayoutHorizontalSpacing
or PM_LayoutVerticalSpacing
returns a negative value.
For binary compatibility reasons, this function is not virtual. If you want to specify custom layout spacings in a QStyle subclass, implement a slot called layoutSpacingImplementation()
. QStyle will discover the slot at run-time (using Qt's meta-object system) and direct all calls to layoutSpacing()
to layoutSpacingImplementation()
.
combinedLayoutSpacing()
, and layoutSpacingImplementation()
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |