Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
doc_src_styles.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
6 if (down)
8 if (tristate && noChange)
10 else
11 opt.state |= checked ? QStyle::State_On :
13 if (q->testAttribute(Qt::WA_Hover) && q->underMouse()) {
14 if (hovering)
16 else
17 opt.state &= ~QStyle::State_MouseOver;
18 }
21 opt.iconSize = q->iconSize();
23
24
29 if (widget->hasFocus())
33 if (widget->underMouse())
37#ifdef QT_KEYPAD_NAVIGATION
38 if (widget->hasEditFocus())
39 state |= QStyle::State_HasEditFocus;
40#endif
41
47
48
51 QStyleOptionButton opt = d->getStyleOption();
52 p.drawControl(QStyle::CE_CheckBox, opt);
54
55
58 subopt.rect = subElementRect(SE_CheckBoxIndicator, btn, widget);
59 drawPrimitive(PE_IndicatorCheckBox, &subopt, p, widget);
60 subopt.rect = subElementRect(SE_CheckBoxContents, btn, widget);
61 drawControl(CE_CheckBoxLabel, &subopt, p, widget);
62
63 if (btn->state & State_HasFocus) {
65 fropt.QStyleOption::operator=(*btn);
66 fropt.rect = subElementRect(SE_CheckBoxFocusRect, btn, widget);
67 drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
68 }
70
71
73 const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt);
75
76 if (!styleHint(SH_UnderlineShortcut, btn, widget))
80 if (!btn->icon.isNull()) {
82 drawItemPixmap(p, btn->rect, alignment, pix);
85 else
87 }
88 if (!btn->text.isEmpty()){
90 btn->palette, btn->state & State_Enabled, btn->text, QPalette::WindowText);
91 }
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
Definition qicon.cpp:1019
@ Disabled
Definition qicon.h:22
@ Normal
Definition qicon.h:22
QPixmap pixmap(const QSize &size, Mode mode=Normal, State state=Off) const
Returns a pixmap with the requested size, mode, and state, generating one if necessary.
Definition qicon.cpp:834
@ WindowText
Definition qpalette.h:51
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
\inmodule QtCore\reentrant
Definition qrect.h:30
constexpr void setRight(int pos) noexcept
Sets the right edge of the rectangle to the given x coordinate.
Definition qrect.h:197
constexpr void setLeft(int pos) noexcept
Sets the left edge of the rectangle to the given x coordinate.
Definition qrect.h:191
constexpr int left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
Definition qrect.h:173
constexpr int right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
Definition qrect.h:179
constexpr int width() const noexcept
Returns the width.
Definition qsize.h:130
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:192
\variable QStyleOptionHeaderV2::textElideMode
\variable QStyleOption::palette
QStyle::State state
QPalette palette
void initFrom(const QWidget *w)
Qt::LayoutDirection direction
The QStylePainter class is a convenience class for drawing QStyle elements inside a widget.
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
Definition qstyle.h:29
@ State_MouseOver
Definition qstyle.h:80
@ State_Sunken
Definition qstyle.h:69
@ State_HasFocus
Definition qstyle.h:75
@ State_Active
Definition qstyle.h:83
@ State_Off
Definition qstyle.h:70
@ State_NoChange
Definition qstyle.h:71
@ State_KeyboardFocusChange
Definition qstyle.h:90
@ State_Enabled
Definition qstyle.h:67
@ State_On
Definition qstyle.h:72
@ State_None
Definition qstyle.h:66
@ CE_CheckBox
Definition qstyle.h:175
QWidget * window() const
Returns the window for this widget, i.e.
Definition qwidget.cpp:4313
Qt::LayoutDirection layoutDirection
the layout direction for this widget.
Definition qwidget.h:170
QPalette palette
the widget's palette
Definition qwidget.h:132
QFontMetrics fontMetrics() const
Returns the font metrics for the widget's current font.
Definition qwidget.h:847
QRect rect
the internal geometry of the widget excluding any window frame
Definition qwidget.h:116
bool isEnabled() const
Definition qwidget.h:814
bool hasFocus() const
Definition qwidget.cpp:6446
bool underMouse() const
Returns true if the widget is under the mouse cursor; otherwise returns false.
Definition qwidget.h:859
bool isActiveWindow
whether this widget's window is the active window
Definition qwidget.h:139
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition qwidget.h:910
QOpenGLWidget * widget
[1]
opt icon
drawPrimitive(PE_IndicatorCheckBox, &subopt, p, widget)
rect
[4]
QPixmap pix
QStyleOptionButton subopt
[2]
uint alignment
opt text
QStylePainter p(this)
[1]
direction
QStyleOptionButton opt
fontMetrics
p drawControl(QStyle::CE_CheckBox, opt)
else opt state
[0]
QRect textRect
const QStyleOptionButton * btn
[3]
@ AlignVCenter
Definition qnamespace.h:155
@ AlignLeft
Definition qnamespace.h:144
@ WA_Hover
Definition qnamespace.h:340
@ WA_KeyboardFocusChange
Definition qnamespace.h:344
@ RightToLeft
@ TextHideMnemonic
Definition qnamespace.h:178
@ TextShowMnemonic
Definition qnamespace.h:173
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLfloat GLfloat p
[1]
unsigned int uint
Definition qtypes.h:34