# class KStyle

###

Module | kdeui
Namespace |
Class | KStyle
Inherits | QStyle

Makes style coding more convenient.

To do: and allows to style KDE specific widgets.

KStyle strives to ease style development by implementing various QStyle methods. These implementations are based on -# the concept of Layout Properties. These properties can be set using setWidgetLayoutProp(). KStyle uses this information to respect various metrics (like space between primitives or margins around widget contents) or turn specific features on or off. -# the concept of KStyle Primitives. These can be implemented by overriding drawKStylePrimitive() and providing drawing methods for specific primitives. Often, the drawing of more complex widgets consists of several primitives.

In the following modules, information about related members is collected: - OptionGroup - WidgetGroup

Author Maksim Orlovich (maksim\@kde.org) Author Sandro Giessl (giessl\@kde.org)

See also KStyleFactory for how to implement the style plugin interface.

### enums

- MarginOffsets { MainMargin, Top, Bot, Left, Right, MarginInc }
- WidgetType { WT_Generic, WT_PushButton, WT_Splitter, WT_CheckBox, WT_RadioButton, WT_DockWidget, WT_ProgressBar, WT_MenuBar, WT_MenuBarItem, WT_Menu, WT_MenuItem, WT_ScrollBar, WT_TabBar, WT_TabWidget, WT_Slider, WT_Tree, WT_SpinBox, WT_ComboBox, WT_Header, WT_LineEdit, WT_GroupBox, WT_StatusBar, WT_ToolBar, WT_ToolButton, WT_ToolBoxTab, WT_Window, WT_Limit }

enum details

### methods

- KStyle ( )

  returns ctor

- centerRect (in, w, h)

  returns QRect

  Argument | Type | Default
  --- | --- | ---
  in | QRect |
  w | int |
  h | int |

  Returns a w x h QRect center inside the 'in' rectangle

- centerRect (in, size)

  returns QRect

  Argument | Type | Default
  --- | --- | ---
  in | QRect |
  size | QSize |

  Return a size-dimension QRect centered inside the 'in' rectangle

- defaultStyle ( )

  returns QString
  static

  Returns the default widget style.

- drawComplexControl (cc, opt, p, w)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  cc | QStyle.ComplexControl |
  opt | QStyleOptionComplex |
  p | QPainter |
  w | QWidget |

- drawControl (elem, opt, p, w)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  elem | QStyle.ControlElement |
  opt | QStyleOption |
  p | QPainter |
  w | QWidget |

  QStyle Methods These are methods reimplemented from QStyle. Usually it's not necessary to reimplement them yourself.

  Some of them are there for binary compatibility reasons only; all they do is to call the implementation from QCommonStyle.

- drawInsideRect (p, r)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  p | QPainter |
  r | QRect |

  Draws inside the rectangle using a thinkness 0 pen. This is what drawRect in Qt3 used to do.

- drawItemPixmap (painter, rect, alignment, pixmap)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  painter | QPainter |
  rect | QRect |
  alignment | int |
  pixmap | QPixmap |

- drawItemText (painter, rect, flags, pal, enabled, text, textRole)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  painter | QPainter |
  rect | QRect |
  flags | int |
  pal | QPalette |
  enabled | bool |
  text | QString |
  textRole | QPalette.ColorRole | QPalette.NoRole

- drawKStylePrimitive (widgetType, primitive, opt, r, pal, flags, p, widget, kOpt)

  returns Nothing
  Not implemented

  Argument | Type | Default
  --- | --- | ---
  widgetType | KStyle.WidgetType |
  primitive | int |
  opt | QStyleOption |
  r | QRect |
  pal | QPalette |
  flags | QStyle.State |
  p | QPainter |
  widget | QWidget | 0
  kOpt | Option | 0

  Draws primitives which are used inside KStyle.

  KStyle implements various elements of QStyle.ComplexControl and QStyle.ControlElement for convenience. Usually complex drawing is split into smaller pieces, which can be text, icons, or other KStyle primitives. These are painted by this method.

  Common Qt option parameters are unpacked for convenience, and information from KStyle are passed as a KStyleOption.

  This method is not meant to be accessible from outside KStyle. You should make sure to use the r parameter for the rectangle, since the QStyleOption is generally unaltered from the original request, even if layout indicates a different painting rectangle.

  widgetType - the widget context in which this call is happening in

  primitive - the primitive which should be called. Primitives from the Generic struct are not directly coupled to the widgetType , other primitives are usually defined in the struct corresponding to the widget type.

  opt - Qt option parameters

  r - parameter for the rectangle

  pal - the palette extracted from opt for convenience

  flags - state flags extracted from opt for convenience

  p - used to draw the primitive

  widget - the widget which is painted on

  kOpt - information passed from KStyle

- drawPrimitive (elem, opt, p, w)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  elem | QStyle.PrimitiveElement |
  opt | QStyleOption |
  p | QPainter |
  w | QWidget |

- eventFilter (a0, a1)

  returns bool

  Argument | Type | Default
  --- | --- | ---
  a0 | QObject |
  a1 | QEvent |

- generatedIconPixmap (iconMode, pixmap, opt)

  returns QPixmap

  Argument | Type | Default
  --- | --- | ---
  iconMode | QIcon.Mode |
  pixmap | QPixmap |
  opt | QStyleOption |

- hitTestComplexControl (cc, opt, pt, w)

  returns QStyle.SubControl

  Argument | Type | Default
  --- | --- | ---
  cc | QStyle.ComplexControl |
  opt | QStyleOptionComplex |
  pt | QPoint |
  w | QWidget |

- itemPixmapRect (r, flags, pixmap)

  returns QRect

  Argument | Type | Default
  --- | --- | ---
  r | QRect |
  flags | int |
  pixmap | QPixmap |

- itemTextRect (fm, r, flags, enabled, text)

  returns QRect

  Argument | Type | Default
  --- | --- | ---
  fm | QFontMetrics |
  r | QRect |
  flags | int |
  enabled | bool |
  text | QString |

- pixelMetric (metric, opt, w)

  returns int

  Argument | Type | Default
  --- | --- | ---
  metric | QStyle.PixelMetric |
  opt | QStyleOption | 0
  w | QWidget | 0

- polish (a0)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  a0 | QWidget |

- polish (a0)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  a0 | QApplication |

- polish (a0)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  a0 | QPalette |

- setWidgetLayoutProp (widget, metric, value)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  widget | KStyle.WidgetType |
  metric | int |
  value | int |

- sizeFromContents (type, opt, contentsSize, w)

  returns QSize

  Argument | Type | Default
  --- | --- | ---
  type | QStyle.ContentsType |
  opt | QStyleOption |
  contentsSize | QSize |
  w | QWidget |

- standardPalette ( )

  returns QPalette

- standardPixmap (standardPixmap, opt, widget)

  returns QPixmap

  Argument | Type | Default
  --- | --- | ---
  standardPixmap | QStyle.StandardPixmap |
  opt | QStyleOption |
  widget | QWidget | 0

- styleHint (hint, opt, w, returnData)

  returns int

  Argument | Type | Default
  --- | --- | ---
  hint | QStyle.StyleHint |
  opt | QStyleOption |
  w | QWidget |
  returnData | QStyleHintReturn |

- subControlRect (control, opt, subControl, w)

  returns QRect

  Argument | Type | Default
  --- | --- | ---
  control | QStyle.ComplexControl |
  opt | QStyleOptionComplex |
  subControl | QStyle.SubControl |
  w | QWidget |

- subElementRect (subRect, opt, w)

  returns QRect

  Argument | Type | Default
  --- | --- | ---
  subRect | QStyle.SubElement |
  opt | QStyleOption |
  w | QWidget |

- unpolish (a0)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  a0 | QWidget |

- unpolish (a0)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  a0 | QApplication |

- widgetLayoutProp (widgetType, metric, opt, w)

  returns int

  Argument | Type | Default
  --- | --- | ---
  widgetType | KStyle.WidgetType |
  metric | int |
  opt | QStyleOption | 0
  w | QWidget | 0

  Used to obtain information about KStyle layout properties and metrics.

  The default implementation returns values which are set using setWidgetLayoutProp(), so normally it's not necessary to implement it yourself.

  This method is not meant to be accessible from outside KStyle.

  widgetType - the widget type context where the metric property belongs to

  metric - the value of this property is requested

  opt - Qt option parameters

  w - the actual widget this call is related to

### enums - detail

- MarginOffsets { MainMargin, Top, Bot, Left, Right, MarginInc }

  These constants describe how to access various fields of a margin property. For example, to set an additional top margin of 2 pixels, use

      setWidgetLayoutProp(WT_SomeWidget, SomeWidget.Margin + Top, 2);

  | MainMargin | - | - |
  | Top | - | - |
  | Bot | - | - |
  | Left | - | - |
  | Right | - | - |
  | MarginInc | - | - |

- WidgetType { WT_Generic, WT_PushButton, WT_Splitter, WT_CheckBox, WT_RadioButton, WT_DockWidget, WT_ProgressBar, WT_MenuBar, WT_MenuBarItem, WT_Menu, WT_MenuItem, WT_ScrollBar, WT_TabBar, WT_TabWidget, WT_Slider, WT_Tree, WT_SpinBox, WT_ComboBox, WT_Header, WT_LineEdit, WT_GroupBox, WT_StatusBar, WT_ToolBar, WT_ToolButton, WT_ToolBoxTab, WT_Window, WT_Limit }

  | WT_Generic | - | - |
  | WT_PushButton | - | - |
  | WT_Splitter | - | - |
  | WT_CheckBox | - | - |
  | WT_RadioButton | - | - |
  | WT_DockWidget | - | - |
  | WT_ProgressBar | - | - |
  | WT_MenuBar | - | - |
  | WT_MenuBarItem | - | - |
  | WT_Menu | - | - |
  | WT_MenuItem | - | - |
  | WT_ScrollBar | - | - |
  | WT_TabBar | - | - |
  | WT_TabWidget | - | - |
  | WT_Slider | - | - |
  | WT_Tree | - | - |
  | WT_SpinBox | - | - |
  | WT_ComboBox | - | - |
  | WT_Header | - | - |
  | WT_LineEdit | - | - |
  | WT_GroupBox | - | - |
  | WT_StatusBar | - | - |
  | WT_ToolBar | - | - |
  | WT_ToolButton | - | - |
  | WT_ToolBoxTab | - | - |
  | WT_Window | - | - |
  | WT_Limit | - 0xFFFF | - |