| images |
|
|
- |
| qcommonstyle.cpp |
!
\class QCommonStyle
\brief The QCommonStyle class encapsulates the common Look and Feel of a GUI.
\ingroup appearance
\inmodule QtWidgets
This abstract class implements some of the widget's look and feel
that is common to all GUI styles provided and shipped as part of
Qt.
Since QCommonStyle inherits QStyle, all of its functions are fully documented
in the QStyle documentation.
\omit
, although the
extra functions that QCommonStyle provides, e.g.
drawComplexControl(), drawControl(), drawPrimitive(),
hitTestComplexControl(), subControlRect(), sizeFromContents(), and
subElementRect() are documented here.
\endomit
\sa QStyle, QProxyStyle
|
267869 |
- |
| qcommonstyle.h |
|
2981 |
- |
| qcommonstyle_p.h |
|
5034 |
- |
| qcommonstylepixmaps_p.h |
XPM |
11176 |
- |
| qdrawutil.cpp |
!
\headerfile <qdrawutil.h>
\inmodule QtWidgets
\title Drawing Utility Functions
\sa QPainter
|
43810 |
- |
| qdrawutil.h |
|
5849 |
- |
| qfusionstyle.cpp |
|
155044 |
- |
| qfusionstyle_p.h |
|
3719 |
- |
| qfusionstyle_p_p.h |
|
4193 |
- |
| qpixmapstyle.cpp |
!
\class QPixmapStyle
\brief The QPixmapStyle class provides mechanism for writing pixmap based styles.
\since 5.7
\ingroup appearance
\inmodule QtWidgets
\internal
This is a convenience class that enables the implementation of a widget style using
pixmaps, on the same fashion used by the \l{BorderImage} QML type.
In order to style a QWidget, one simply needs to call QPixmapStyle::addDescriptor()
or QPixmapStyle::addPixmap() with the id of the component to be styled, the path of
the image to be used, the margins and the tiling rules:
\snippet styles/qcustompixmapstyle.cpp 0
\sa QStyle, QCommonStyle
|
41690 |
- |
| qpixmapstyle_p.h |
|
8175 |
- |
| qpixmapstyle_p_p.h |
|
1528 |
- |
| qproxystyle.cpp |
!
\class QProxyStyle
\brief The QProxyStyle class is a convenience class that simplifies
dynamically overriding QStyle elements.
\since 4.6
\inmodule QtWidgets
A QProxyStyle wraps a QStyle (usually the default system style) for the
purpose of dynamically overriding painting or other specific style behavior.
It is the recommended way to adjust the platform style in a production
application; see \l{Styling Approaches for Qt Widgets}.
The following example shows how to override the shortcut underline
behavior on any platform:
\snippet code/src_gui_qproxystyle.cpp 1
Warning: The \l {QCommonStyle} {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 \macos, for
example, where menus are handled by the operating system.
When a proxy style should be set on a specific widget only, you have
to make sure to not set the proxy on the global application style which
is returned by QWidget::style(). You have to create a separate custom style
for the widget similar to:
\snippet code/src_gui_qproxystyle.cpp 2
\sa QStyle
|
11598 |
- |
| qproxystyle.h |
|
3557 |
- |
| qproxystyle_p.h |
|
1069 |
- |
| qstyle.cpp |
!
\page qwidget-styling.html
\title Styling
Qt's built-in widgets use the QStyle class to perform nearly all
of their drawing. QStyle is an abstract base class that
encapsulates the look and feel of a GUI, and can be used to make
the widgets look exactly like the equivalent native widgets or to
give the widgets a custom look.
Qt provides a set of QStyle implementations that match the native
look of the platforms it supports. The \c windows and \c fusion
styles are built into the Qt Widgets module; the platform styles,
such as \c windows11 and \c macos, are loaded as plugins.
QStyleFactory lists the styles that are available at runtime.
Applications can also provide their own styles, either linked in or
as plugins.
Most functions for drawing style elements take four arguments:
\list
\li an enum value specifying which graphical element to draw
\li a QStyleOption object specifying how and where to render that element
\li a QPainter object that should be used to draw the element
\li a QWidget object on which the drawing is performed (optional)
\endlist
The style gets all the information it needs to render the
graphical element from the QStyleOption class. The widget is
passed as the last argument in case the style needs it to perform
special effects (such as animated default buttons on \macos),
but it isn't mandatory. In fact, QStyle can be used to draw on any
paint device (not just widgets), in which case the widget argument
is a zero pointer.
\image paintsystem-stylepainter.png
{Diagram showing QStylePainter inherits from QPainter}
The paint system also provides the QStylePainter class inheriting
from QPainter. QStylePainter is a convenience class for drawing
QStyle elements inside a widget, and extends QPainter with a set
of high-level drawing functions implemented on top of QStyle's
API. The advantage of using QStylePainter is that the parameter
lists get considerably shorter.
\table 100%
\row
\li \inlineimage paintsystem-icon.png {Icon used in Qt}
\li \b QIcon
The QIcon class provides scalable icons in different modes and states.
QIcon can generate pixmaps reflecting an icon's state, mode and
size. These pixmaps are generated from the set of pixmaps
made available to the icon, and are used by Qt widgets to show an
icon representing a particular action.
The rendering of a QIcon object is handled by the QIconEngine
class. Each icon has a corresponding icon engine that is
responsible for drawing the icon with a requested size, mode and
state.
\endtable
For more information about widget styling and appearance, see
\l{Styles and Style Aware Widgets} and
\l{Styling Approaches for Qt Widgets}.
|
112407 |
- |
| qstyle.h |
|
26779 |
- |
| qstyle_p.h |
|
2558 |
- |
| qstyleanimation.cpp |
! \internal
A helper function to blend two images.
The result consists of ((alpha)*startImage) + ((1-alpha)*endImage)
|
7573 |
- |
| qstyleanimation_p.h |
|
3318 |
- |
| qstylefactory.cpp |
!
\class QStyleFactory
\brief The QStyleFactory class creates QStyle objects.
\ingroup appearance
\inmodule QtWidgets
The QStyle class is an abstract base class that encapsulates the
look and feel of a GUI. QStyleFactory creates a QStyle object
using the create() function and a key identifying the style. The
styles are either built-in or dynamically loaded from a style
plugin (see QStylePlugin).
Use the keys() function to retrieve the valid keys. The built-in
styles, typically "windows" and "fusion", are always available. The
platform styles are plugins and are available on their platform only:
"windows11", which follows the Windows 11 Fluent design, and
"windowsvista" on Windows, "macos" on \macos, and "android" on Android.
The keys are case-insensitive.
\sa QStyle
|
3253 |
- |
| qstylefactory.h |
|
519 |
- |
| qstylehelper.cpp |
|
15936 |
- |
| qstylehelper_p.h |
|
2964 |
- |
| qstyleoption.cpp |
!
\class QStyleOption
\brief The QStyleOption class stores the parameters used by QStyle functions.
\ingroup appearance
\inmodule QtWidgets
QStyleOption and its subclasses contain all the information that
QStyle functions need to draw a graphical element.
For performance reasons, there are few member functions and the
access to the member variables is direct (i.e., using the \c . or
\c -> operator). This makes the structures straightforward to use
and emphasizes that these are simply parameters used by the style
functions.
The caller of a QStyle function usually creates QStyleOption
objects on the stack. This combined with Qt's extensive use of
\l{implicit sharing} for types such as QString, QPalette, and
QColor ensures that no memory allocation needlessly takes place.
The following code snippet shows how to use a specific
QStyleOption subclass to paint a push button:
\snippet qstyleoption/main.cpp 0
In our example, the control is a QStyle::CE_PushButton, and
according to the QStyle::drawControl() documentation the
corresponding class is QStyleOptionButton.
When reimplementing QStyle functions that take a QStyleOption
parameter, you often need to cast the QStyleOption to a subclass.
For safety, you can use qstyleoption_cast() to ensure that the
pointer type is correct. For example:
\snippet qstyleoption/main.cpp 4
The qstyleoption_cast() function will return 0 if the object to
which \c option points is not of the correct type.
\sa QStyle, QStylePainter
|
112075 |
- |
| qstyleoption.h |
|
23413 |
- |
| qstylepainter.cpp |
!
\class QStylePainter
\brief The QStylePainter class is a convenience class for drawing QStyle
elements inside a widget.
\ingroup appearance
\ingroup painting
\inmodule QtWidgets
QStylePainter extends QPainter with a set of high-level \c
draw...() functions implemented on top of QStyle's API. The
advantage of using QStylePainter is that the parameter lists get
considerably shorter. Whereas a QStyle object must be able to
draw on any widget using any painter (because the application
normally has one QStyle object shared by all widget), a
QStylePainter is initialized with a widget, eliminating the need
to specify the QWidget, the QPainter, and the QStyle for every
function call.
Example using QStyle directly:
\snippet styles/styles.cpp 1
Example using QStylePainter:
\snippet styles/styles.cpp 0
\snippet styles/styles.cpp 4
\snippet styles/styles.cpp 6
\sa QStyle, QStyleOption
|
3964 |
- |
| qstylepainter.h |
|
2582 |
- |
| qstyleplugin.cpp |
!
\class QStylePlugin
\brief The QStylePlugin class provides an abstract base for custom QStyle plugins.
\ingroup plugins
\inmodule QtWidgets
QStylePlugin is a simple plugin interface that makes it easy
to create custom styles that can be loaded dynamically into
applications using the QStyleFactory class.
Writing a style plugin is achieved by subclassing this base class,
reimplementing the pure virtual create() function, and
exporting the class using the Q_PLUGIN_METADATA() macro.
\snippet qstyleplugin/main.cpp 0
The json metadata file \c mystyleplugin.json for the plugin needs
to contain information about the names of the styles the plugins
supports as follows:
\quotefile qstyleplugin/mystyleplugin.json
See \l {How to Create Qt Plugins} for details.
\sa QStyleFactory, QStyle
|
2054 |
- |
| qstyleplugin.h |
|
712 |
- |
| qstylesheetstyle.cpp |
RECURSION_GUARD:
the QStyleSheetStyle is a proxy. If used with others proxy style, we may end up with something like:
QStyleSheetStyle -> ProxyStyle -> QStyleSheetStyle -> OriginalStyle
Recursion may happen if the style call the widget()->style() again.
Not to mention the performance penalty of having two lookup of rules.
The first instance of QStyleSheetStyle will set globalStyleSheetStyle to itself. The second one
will notice the globalStyleSheetStyle is not istelf and call its base style directly.
|
275284 |
- |
| qstylesheetstyle_default.cpp |
This is the default Qt style sheet.
IMPORTANT: This style sheet is primarily meant for defining feature
capabilities of styles. Do NOT add default styling rules here. When in
doubt ask the stylesheet maintainer.
The stylesheet in here used to be in a CSS file, but was moved here to
avoid parsing overhead.
|
13072 |
- |
| qstylesheetstyle_p.h |
|
8258 |
- |
| qwindowsstyle.cpp |
\internal
|
93523 |
- |
| qwindowsstyle_p.h |
|
2625 |
- |
| qwindowsstyle_p_p.h |
|
2058 |
- |