Qt logo

QStyle Class Reference


Encapsulates common Look and Feel of a GUI. More...

#include <qstyle.h>

Inherits QObject.

Inherited by QCommonStyle.

List of all member functions.

Public Members


Detailed Description

Encapsulates common Look and Feel of a GUI.

While it is not possible to fully enumerate the look of graphic elements and the feel of widgets in a GUI, a large number of elements are common to many widgets. The QStyle class allows the look of these elements to be modified across all widgets that use the QStyle methods. It also provides two feel options - Motif and Windows.

In previous versions of Qt, the look and feel option for widgets was specified by a single value - the GUIStyle. Starting with Qt 2.0, this notion has been expanded to allow the look to be specified by virtual drawing functions.

Derived classes may override some or all of the drawing functions to modify the look of all widgets which utilize those functions.

Examples: themes/main.cpp


Member Function Documentation

QStyle::~QStyle () [virtual]

Destructs the style.

QRect QStyle::buttonRect ( int x, int y, int w, int h ) [virtual]

Returns the rectangle available for contents in a push button. Usually this is the entire rectangle but it may also be smaller when you think about rounded buttons.

Reimplemented in QPlatinumStyle.

QRect QStyle::comboButtonFocusRect ( int x, int y, int w, int h ) [virtual]

Returns the rectangle used to draw the the focus rectangle in a combo box.

Reimplemented in QPlatinumStyle, QCommonStyle and QWindowsStyle.

QRect QStyle::comboButtonRect ( int x, int y, int w, int h ) [virtual]

Returns the rectangle available for contents in a combo box button. Usually this is the entire rectangle without the nifty menu indicator, but it may also be smaller when you think about rounded buttons.

Reimplemented in QWindowsStyle, QCommonStyle and QPlatinumStyle.

int QStyle::defaultFrameWidth () const [virtual]

The default frame width, usually 2.

Reimplemented in QCommonStyle and QCDEStyle.

void QStyle::drawArrow ( QPainter * p, Qt::ArrowType type, bool down, int x, int y, int w, int h, const QColorGroup & g, bool enabled, const QBrush * fill = 0 ) [virtual]

Draws a button indicating direction.

void QStyle::drawBevelButton ( QPainter *, int, int, int, int, const QColorGroup &, bool = FALSE, const QBrush * = 0 ) [virtual]

Draws a press-sensitive shape in the style of a bevel button.

Reimplemented in QMotifStyle, QWindowsStyle and QPlatinumStyle.

void QStyle::drawButton ( QPainter *, int, int, int, int, const QColorGroup &, bool = FALSE, const QBrush * = 0 ) [virtual]

Draws a press-sensitive shape in the style of a full featured push button.

Reimplemented in QPlatinumStyle, QMotifStyle and QWindowsStyle.

void QStyle::drawButtonMask ( QPainter *, int, int, int, int ) [virtual]

Draw the mask of a pushbutton. Useful if a rounded pushbuttons needs to be transparent because the style uses a fancy background pixmap.

void QStyle::drawComboButton ( QPainter * p, int x, int y, int w, int h, const QColorGroup & g, bool sunken = FALSE, bool editable = FALSE, bool enabled = TRUE, const QBrush * fill = 0 ) [virtual]

Draws a press-sensitive shape in the style of a combo box or menu button.

Reimplemented in QPlatinumStyle, QWindowsStyle and QCommonStyle.

void QStyle::drawComboButtonMask ( QPainter * p, int x, int y, int w, int h ) [virtual]

Draw the mask of a combo box button. Useful if a rounded buttons needs to be transparent because the style uses a fancy background pixmap.

Reimplemented in QCommonStyle.

void QStyle::drawExclusiveIndicator ( QPainter *, int x, int y, int w, int h, const QColorGroup &, bool on, bool down = FALSE, bool enabled = TRUE ) [virtual]

Draws a mark indicating the state of an exclusive choice.

Reimplemented in QWindowsStyle, QMotifStyle, QPlatinumStyle and QCDEStyle.

void QStyle::drawExclusiveIndicatorMask ( QPainter * p, int x, int y, int w, int h, bool ) [virtual]

Draws the mask of a mark indicating the state of an exclusive choice.

Reimplemented in QMotifStyle and QWindowsStyle.

void QStyle::drawFocusRect ( QPainter * p, const QRect & r, const QColorGroup & g, const QColor * = 0, bool atBorder = FALSE ) [virtual]

Draws a mark indicating keyboard focus is on r. atBorder indicates whether the focus rectangle is at the border of an item (for example an item in a listbox). Certain styles (Motif style as the most prominent example) might have to shrink the rectangle a bit in that case to ensure that the focus rectangle is visible at all.

Reimplemented in QWindowsStyle and QMotifStyle.

void QStyle::drawIndicator ( QPainter *, int, int, int, int, const QColorGroup &, int state, bool = FALSE, bool = TRUE ) [virtual]

Draws a mark indicating the state of a choice.

Reimplemented in QCDEStyle, QMotifStyle, QPlatinumStyle and QWindowsStyle.

void QStyle::drawIndicatorMask ( QPainter * p, int x, int y, int w, int h, int ) [virtual]

Draws the mask of a mark indicating the state of a choice.

Reimplemented in QPlatinumStyle.

void QStyle::drawItem ( QPainter * p, int x, int y, int w, int h, int flags, const QColorGroup & g, bool enabled, const QPixmap * pixmap, const QString & text, int len=-1, const QColor * penColor = 0 ) [virtual]

Draw text or a pixmap in an area.

void QStyle::drawPanel ( QPainter * p, int x, int y, int w, int h, const QColorGroup & g, bool sunken=FALSE, int lineWidth = 1, const QBrush * fill = 0 ) [virtual]

Draws a panel to separate parts of the visual interface.

Reimplemented in QWindowsStyle.

void QStyle::drawPopupPanel ( QPainter * p, int x, int y, int w, int h, const QColorGroup & cg, int lineWidth = 2, const QBrush * fill = 0 ) [virtual]

Draws a panel suitable as frame for popup windows.

Reimplemented in QWindowsStyle and QPlatinumStyle.

void QStyle::drawPushButton ( QPushButton *, QPainter * ) [virtual]

Draws a pushbutton. This function will normally call drawButton() with arguments according to the current state of the pushbutton.

See also: drawPushButtonLabel() and QPushButton::drawButton().

Reimplemented in QPlatinumStyle, QMotifStyle and QWindowsStyle.

void QStyle::drawPushButtonLabel ( QPushButton *, QPainter * ) [virtual]

Draws the label of a pushbutton. This function will normally call drawItem() with arguments according to the current state of the pushbutton.

See also: drawPushButton() and QPushButton::drawButtonLabel().

Reimplemented in QCommonStyle and QPlatinumStyle.

void QStyle::drawRect ( QPainter * p, int x, int y, int w, int h, const QColor & c, int lineWidth = 1, const QBrush * fill = 0 ) [virtual]

Draws a simple rectangle to separate parts of the visual interface.

void QStyle::drawRectStrong ( QPainter * p, int x, int y, int w, int h, const QColorGroup & g, bool sunken=FALSE, int lineWidth = 1, int midLineWidth = 0, const QBrush * fill = 0 ) [virtual]

Draws an emphasized rectangle to strongly separate parts of the visual interface.

void QStyle::drawScrollBarControls ( QPainter *, const QScrollBar *, int sliderStart, uint controls, uint activeControl ) [virtual]

Draws the given scrollbar. Used internally by QScrollbar.

The controls are either ADD_LINE, SUB_LINE, ADD_PAGE, SUB_PAGE, FIRST, LAST, SLIDER or NONE

Controls is a combination of these, activeControl is the control currently pressed down.

Reimplemented in QPlatinumStyle, QMotifStyle and QWindowsStyle.

void QStyle::drawSeparator ( QPainter * p, int x1, int y1, int x2, int y2, const QColorGroup & g, bool sunken = TRUE, int lineWidth = 1, int midLineWidth = 0 ) [virtual]

Draws a line to separate parts of the visual interface.

void QStyle::drawSlider ( QPainter * p, int x, int y, int w, int h, const QColorGroup & g, Orientation, bool tickAbove, bool tickBelow ) [virtual]

Draws a slider.

Reimplemented in QPlatinumStyle, QMotifStyle and QWindowsStyle.

void QStyle::drawSliderGroove ( QPainter * p, int x, int y, int w, int h, const QColorGroup & g, QCOORD c, Orientation ) [virtual]

Draws a slider groove.

Reimplemented in QWindowsStyle, QPlatinumStyle and QMotifStyle.

void QStyle::drawSliderGrooveMask ( QPainter * p, int x, int y, int w, int h, QCOORD c, Orientation ) [virtual]

Draws the mask of a slider groove.

Reimplemented in QCommonStyle.

void QStyle::drawSliderMask ( QPainter * p, int x, int y, int w, int h, Orientation, bool, bool ) [virtual]

Draws the mask of a slider.

Reimplemented in QWindowsStyle and QCommonStyle.

void QStyle::drawSplitter ( QPainter * p, int x, int y, int w, int h, const QColorGroup & g, Orientation orient ) [virtual]

Draws a splitter handle in the rectangle described by x, y, w, h using painter p and color group g. The orientation is orient.

See also: splitterWidth().

Reimplemented in QMotifStyle and QWindowsStyle.

void QStyle::drawTab ( QPainter * p, const QTabBar * tb, QTab * t, bool selected ) [virtual]

TODO.

Reimplemented in QMotifStyle, QWindowsStyle and QCommonStyle.

void QStyle::drawTabMask ( QPainter * p, const QTabBar * tb, QTab * t, bool selected ) [virtual]

TODO.

Reimplemented in QWindowsStyle, QMotifStyle and QCommonStyle.

void QStyle::drawToolButton ( QPainter * p, int x, int y, int w, int h, const QColorGroup & g, bool sunken = FALSE, const QBrush * fill = 0 ) [virtual]

Draws a press-sensitive shape in the style of a toolbar button

The default implementation calls drawBevelButton()

See also: drawBevelButton().

QSize QStyle::exclusiveIndicatorSize () const [virtual]

Returns the size of the mark used to indicate exclusive choice.

Reimplemented in QPlatinumStyle, QMotifStyle and QWindowsStyle.

int QStyle::extraPopupMenuItemWidth ( bool checkable, int maxpmw, QMenuItem * mi, const QFontMetrics & fm ) [virtual]

Returns the extra width of a menu item mi, that means all extra pixels besides the space the menu item text requires. checkable defines, whether the menu has a check column. maxpmw is the maximium width of all iconsets within a check column and fm defines the font metrics used to draw the label. This is particulary useful to calculate a suitable size for a submenu indicator or the column separation, including the tab column used to indicate item accelerators.

Reimplemented in QPlatinumStyle and QWindowsStyle.

void QStyle::getButtonShift ( int & x, int & y ) [virtual]

Some GUI styles shift the contents of a button when the button is down. The default implementation returns 0 for both x and y.

Reimplemented in QWindowsStyle and QCommonStyle.

GUIStyle QStyle::guiStyle () const

Returns an indicator to the additional "feel" component of a style. Current supported values are Windows and Motif.

QSize QStyle::indicatorSize () const [virtual]

Returns the size of the mark used to indicate choice.

Reimplemented in QPlatinumStyle, QWindowsStyle and QMotifStyle.

QRect QStyle::itemRect ( QPainter * p, int x, int y, int w, int h, int flags, bool enabled, const QPixmap * pixmap, const QString & text, int len=-1 ) [virtual]

Returns the appropriate area within a rectangle in which to draw text or a pixmap.

int QStyle::maximumSliderDragDistance () const [virtual]

Some feels require the scrollbar or other sliders to jump back to the original position when the mouse pointer is too far away while dragging.

This behavior can be customized with this function. The default is -1 (no jump back) while Windows requires 20 (weird jump back).

Reimplemented in QPlatinumStyle, QCommonStyle and QWindowsStyle.

void QStyle::polish ( QApplication * ) [virtual]

Late initialization of the QApplication object.

See also: unPolish.

Reimplemented in QMotifStyle.

void QStyle::polish ( QPalette & ) [virtual]

The style may have certain requirements for color palettes. In this function it has the chance to change the palette according to these requirements.

See also: unPolish, QPalette and QApplication::setPalette().

void QStyle::polish ( QWidget * ) [virtual]

Initializes the appearance of a widget.

This function is called for every widget, after it has been fully created just before it is shown the very first time.

Reasonable actions in this function might be to set the of the widget and the background pixmap, for example. Unreasonable use would be setting the geometry!

The QWidget::inherits() function may provide enough information to allow class-specific customizations. But be careful not to hard-code things too much, as new QStyle sub-classes will be expected to work reasonably with all current and future widgets.

See also: unPolish(QWidget*).

void QStyle::scrollBarMetrics ( const QScrollBar *, int &, int &, int &, int & ) [virtual]

Returns the metrics of the passed scrollbar: sliderMin, sliderMax, sliderLength and buttonDim.

Reimplemented in QPlatinumStyle, QWindowsStyle and QMotifStyle.

int QStyle::sliderLength () const [virtual]

The length of a slider.

Reimplemented in QPlatinumStyle, QMotifStyle and QWindowsStyle.

int QStyle::splitterWidth () const [virtual]

Returns the width of a splitter handle.

See also: drawSplitter().

Reimplemented in QMotifStyle and QWindowsStyle.

void QStyle::tabbarMetrics ( const QTabBar * t, int & hframe, int & vframe, int & overlap ) [virtual]

TODO.

Reimplemented in QMotifStyle, QWindowsStyle and QCommonStyle.

void QStyle::unPolish ( QApplication * ) [virtual]

Redo the application polish

See also: polish.

void QStyle::unPolish ( QWidget * ) [virtual]

Undos the initializataion of a widget's appearance

This function is the counterpart to polish. Is is called for every polished widget when the style is dynamically changed. The former style has to un-polish its settings before the new style can polish them again.

See also: polish(QWidget*).


Search the documentation, FAQ, qt-interest archive and more (uses www.troll.no):


This file is part of the Qt toolkit, copyright © 1995-99 Troll Tech, all rights reserved.


Copyright İ 1999 Troll TechTrademarks
Qt version 2.0.2