QProxyStyle Class Reference

The QProxyStyle class is a convenience class that simplifies dynamically overriding QStyle elements.

  1. #include <QProxyStyle>

Inherits: QCommonStyle.

This class was introduced in Qt 4.6.

Detailed Description

The QProxyStyle class is a convenience class that simplifies dynamically overriding QStyle elements.

A QProxyStyle wraps a QStyle (usually the default system style) for the purpose of dynamically overriding painting or other specific style behavior.

The following example shows how to override the shortcut underline behavior on any platform:

  1. #include "textedit.h"
  2. #include <QApplication>
  3. #include <QProxyStyle>
  4.  
  5. class MyProxyStyle : public QProxyStyle
  6.  {
  7.   public:
  8.     int styleHint(StyleHint hint, const QStyleOption *option = 0,
  9.                   const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const
  10.      {
  11.         if (hint == QStyle::SH_UnderlineShortcut)
  12.             return 0;
  13.         return QProxyStyle::styleHint(hint, option, widget, returnData);
  14.     }
  15. };
  16.  
  17. int main(int argc, char **argv)
  18.  {
  19.     Q_INIT_RESOURCE(textedit);
  20.  
  21.     QApplication a(argc, argv);
  22.     a.setStyle(new MyProxyStyle);
  23.     TextEdit mw;
  24.     mw.resize(700, 800);
  25.     mw.show();
  26.     //...
  27. }

Warning: The common styles provided by Qt will respect this hint, because they call QStyle::proxy(), but there is no guarantee that QStyle::proxy() will be called for user defined or system controlled styles. It would not work on a Mac, for example, where menus are handled by the operating system.

See also QStyle.

Public Functions

Toggle details QProxyStyle

QProxyStyleQProxyStyle ( QStyle *style=0 ) ( QStyle *style=0 )

Constructs a QProxyStyle object for overriding behavior in style or in the current application style if style is 0 (default). Normally style is 0, because you want to override behavior in the system style.

Ownership of style is transferred to QProxyStyle.

Look up this member in the source code.

Toggle details QProxyStyle

~QProxyStyle~QProxyStyle () ()

Destroys the QProxyStyle object.

Look up this member in the source code.

Toggle details QStyle * QProxyStyle

baseStylebaseStyle () ()const

Returns the proxy base style object. If no base style is set on the proxy style, QProxyStyle will create an instance of the application style instead.

See also setBaseStyle() and QStyle.

Look up this member in the source code.

Toggle details void QProxyStyle

drawComplexControldrawComplexControl ( ComplexControl control , const QStyleOptionComplex *option , QPainter *painter , const QWidget *widget=0 ...) ( ComplexControl control , const QStyleOptionComplex *option , QPainter *painter , const QWidget *widget=0 )const [virtual]

Reimplemented from QStyle::drawComplexControl().

Look up this member in the source code.

Toggle details void QProxyStyle

drawControldrawControl ( ControlElement element , const QStyleOption *option , QPainter *painter , const QWidget *widget=0 ...) ( ControlElement element , const QStyleOption *option , QPainter *painter , const QWidget *widget=0 )const [virtual]

Reimplemented from QStyle::drawControl().

Look up this member in the source code.

Toggle details void QProxyStyle

drawItemPixmapdrawItemPixmap ( QPainter *painter , const QRect &rect , int alignment , const QPixmap &pixmap ...) ( QPainter *painter , const QRect &rect , int alignment , const QPixmap &pixmap )const [virtual]

Reimplemented from QStyle::drawItemPixmap().

Look up this member in the source code.

Toggle details void QProxyStyle

drawItemTextdrawItemText ( QPainter *painter , const QRect &rect , int flags , const QPalette &pal , bool enabled , const QString &text , QPalette::ColorRole textRole=QPalette::NoRole ...) ( QPainter *painter , const QRect &rect , int flags , const QPalette &pal , bool enabled , const QString &text , QPalette::ColorRole textRole=QPalette::NoRole )const [virtual]

Reimplemented from QStyle::drawItemText().

Look up this member in the source code.

Toggle details void QProxyStyle

drawPrimitivedrawPrimitive ( PrimitiveElement element , const QStyleOption *option , QPainter *painter , const QWidget *widget=0 ...) ( PrimitiveElement element , const QStyleOption *option , QPainter *painter , const QWidget *widget=0 )const [virtual]

Reimplemented from QStyle::drawPrimitive().

Look up this member in the source code.

Toggle details bool QProxyStyle

eventevent ( QEvent *e ) ( QEvent *e ) [virtual protected]

Reimplemented from QObject::event().

Look up this member in the source code.

Toggle details QPixmap QProxyStyle

generatedIconPixmapgeneratedIconPixmap ( QIcon::Mode iconMode , const QPixmap &pixmap , const QStyleOption *opt ...) ( QIcon::Mode iconMode , const QPixmap &pixmap , const QStyleOption *opt )const [virtual]

Reimplemented from QStyle::generatedIconPixmap().

Look up this member in the source code.

Toggle details SubControl QProxyStyle

hitTestComplexControlhitTestComplexControl ( ComplexControl control , const QStyleOptionComplex *option , const QPoint &pos , const QWidget *widget=0 ...) ( ComplexControl control , const QStyleOptionComplex *option , const QPoint &pos , const QWidget *widget=0 )const [virtual]

Reimplemented from QStyle::hitTestComplexControl().

Look up this member in the source code.

Toggle details QRect QProxyStyle

itemPixmapRectitemPixmapRect ( const QRect &r , int flags , const QPixmap &pixmap ...) ( const QRect &r , int flags , const QPixmap &pixmap )const [virtual]

Reimplemented from QStyle::itemPixmapRect().

Look up this member in the source code.

Toggle details QRect QProxyStyle

itemTextRectitemTextRect ( const QFontMetrics &fm , const QRect &r , int flags , bool enabled , const QString &text ...) ( const QFontMetrics &fm , const QRect &r , int flags , bool enabled , const QString &text )const [virtual]

Reimplemented from QStyle::itemTextRect().

Look up this member in the source code.

Toggle details int QProxyStyle

pixelMetricpixelMetric ( PixelMetric metric , const QStyleOption *option=0 , const QWidget *widget=0 ...) ( PixelMetric metric , const QStyleOption *option=0 , const QWidget *widget=0 )const [virtual]

Reimplemented from QStyle::pixelMetric().

Look up this member in the source code.

Toggle details void QProxyStyle

polishpolish ( QWidget *widget ) ( QWidget *widget ) [virtual]

Reimplemented from QStyle::polish().

Look up this member in the source code.

Toggle details void QProxyStyle

polishpolish ( QPalette &pal ) ( QPalette &pal ) [virtual]

Reimplemented from QStyle::polish().

Look up this member in the source code.

Toggle details void QProxyStyle

polishpolish ( QApplication *app ) ( QApplication *app ) [virtual]

Reimplemented from QStyle::polish().

Look up this member in the source code.

Toggle details void QProxyStyle

setBaseStylesetBaseStyle ( QStyle *style ) ( QStyle *style )

Sets the base style that should be proxied.

Ownership of style is transferred to QProxyStyle.

If style is zero, a desktop-dependant style will be assigned automatically.

See also baseStyle().

Look up this member in the source code.

Toggle details QSize QProxyStyle

sizeFromContentssizeFromContents ( ContentsType type , const QStyleOption *option , const QSize &size , const QWidget *widget ...) ( ContentsType type , const QStyleOption *option , const QSize &size , const QWidget *widget )const [virtual]

Reimplemented from QStyle::sizeFromContents().

Look up this member in the source code.

Toggle details QPalette QProxyStyle

standardPalettestandardPalette () ()const [virtual]

Reimplemented from QStyle::standardPalette().

Look up this member in the source code.

Toggle details QPixmap QProxyStyle

standardPixmapstandardPixmap ( StandardPixmap standardPixmap , const QStyleOption *opt , const QWidget *widget=0 ...) ( StandardPixmap standardPixmap , const QStyleOption *opt , const QWidget *widget=0 )const [virtual]

Reimplemented from QStyle::standardPixmap().

Look up this member in the source code.

Toggle details int QProxyStyle

styleHintstyleHint ( StyleHint hint , const QStyleOption *option=0 , const QWidget *widget=0 , QStyleHintReturn *returnData=0 ...) ( StyleHint hint , const QStyleOption *option=0 , const QWidget *widget=0 , QStyleHintReturn *returnData=0 )const [virtual]

Reimplemented from QStyle::styleHint().

Look up this member in the source code.

Toggle details QRect QProxyStyle

subControlRectsubControlRect ( ComplexControl cc , const QStyleOptionComplex *option , SubControl sc , const QWidget *widget ...) ( ComplexControl cc , const QStyleOptionComplex *option , SubControl sc , const QWidget *widget )const [virtual]

Reimplemented from QStyle::subControlRect().

Look up this member in the source code.

Toggle details QRect QProxyStyle

subElementRectsubElementRect ( SubElement element , const QStyleOption *option , const QWidget *widget ...) ( SubElement element , const QStyleOption *option , const QWidget *widget )const [virtual]

Reimplemented from QStyle::subElementRect().

Look up this member in the source code.

Toggle details void QProxyStyle

unpolishunpolish ( QWidget *widget ) ( QWidget *widget ) [virtual]

Reimplemented from QStyle::unpolish().

Look up this member in the source code.

Toggle details void QProxyStyle

unpolishunpolish ( QApplication *app ) ( QApplication *app ) [virtual]

Reimplemented from QStyle::unpolish().

Look up this member in the source code.

    Public Slots

    Toggle details int QProxyStyle

    layoutSpacingImplementationlayoutSpacingImplementation ( QSizePolicy::ControlType control1 , QSizePolicy::ControlType control2 , Qt::Orientation orientation , const QStyleOption *option=0 , const QWidget *widget=0 ...) ( QSizePolicy::ControlType control1 , QSizePolicy::ControlType control2 , Qt::Orientation orientation , const QStyleOption *option=0 , const QWidget *widget=0 )const[protected] [slot]

    This slot is called by 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.

    The default implementation returns -1.

    See also layoutSpacing() and combinedLayoutSpacing().

    Look up this member in the source code.

    Toggle details QIcon QProxyStyle

    standardIconImplementationstandardIconImplementation ( StandardPixmap standardIcon , const QStyleOption *option , const QWidget *widget ...) ( StandardPixmap standardIcon , const QStyleOption *option , const QWidget *widget )const[protected] [slot]

    Returns an icon for the given standardIcon.

    Reimplement this slot to provide your own icons in a QStyle subclass. The option argument can be used to pass extra information required to find the appropriate icon. The widget argument is optional and can also be used to help find the icon.

    Note: Because of binary compatibility constraints, standardIcon() introduced in Qt 4.1 is not virtual. Therefore it must dynamically detect and call this slot. This default implementation simply calls standardIcon() with the given parameters.

    See also standardIcon().

    Look up this member in the source code.

      Notes provided by the Qt Community

      No notes