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
qwidget.cpp File Reference

(35cdd8abf69b57408de45643eb4de161773149f2)

#include "qapplication.h"
#include "qapplication_p.h"
#include "qbrush.h"
#include "qcursor.h"
#include "private/qduplicatetracker_p.h"
#include "qevent.h"
#include "qlayout.h"
#include "qmetaobject.h"
#include "qpixmap.h"
#include "qpointer.h"
#include "qstack.h"
#include "qstyle.h"
#include "qstylefactory.h"
#include "qvariant.h"
#include "qwidget.h"
#include "qstyleoption.h"
#include "qstylehints.h"
#include <qpa/qplatformwindow.h>
#include <qpa/qplatformwindow_p.h>
#include "private/qwidgetwindow_p.h"
#include "qpainter.h"
#include "qdebug.h"
#include "private/qstylesheetstyle_p.h"
#include "private/qstyle_p.h"
#include "qfileinfo.h"
#include "qscopeguard.h"
#include <QtGui/private/qhighdpiscaling_p.h>
#include <QtGui/qinputmethod.h>
#include <qbackingstore.h>
#include <private/qwidgetrepaintmanager_p.h>
#include <private/qpaintengine_raster_p.h>
#include "qwidget_p.h"
#include <QtGui/private/qwindow_p.h>
#include "qlayout_p.h"
#include "QtWidgets/qabstractscrollarea.h"
#include "private/qabstractscrollarea_p.h"
#include "private/qevent_p.h"
#include "private/qgesturemanager_p.h"
#include "qwindowcontainer_p.h"
#include <sstream>
#include "moc_qwidget.cpp"
#include "moc_qwidget_p.cpp"
+ Include dependency graph for qwidget.cpp:

Go to the source code of this file.

Classes

struct  QWidgetExceptionCleaner
 
struct  MapToGlobalTransformResult
 

Macros

#define FOCUS_NEXT(w)   w->d_func()->focus_next
 
#define FOCUS_PREV(w)   w->d_func()->focus_prev
 

Functions

 Q_LOGGING_CATEGORY (lcWidgetPainting, "qt.widgets.painting", QtWarningMsg)
 
 Q_LOGGING_CATEGORY (lcWidgetShowHide, "qt.widgets.showhide", QtWarningMsg)
 
 Q_LOGGING_CATEGORY (lcWidgetWindow, "qt.widgets.window", QtWarningMsg)
 
static bool qRectIntersects (const QRect &r1, const QRect &r2)
 
bool qt_sendSpontaneousEvent (QObject *, QEvent *)
 
static bool q_evaluateRhiConfigRecursive (const QWidget *w, QPlatformBackingStoreRhiConfig *outConfig, QSurface::SurfaceType *outType)
 
bool q_evaluateRhiConfig (const QWidget *w, QPlatformBackingStoreRhiConfig *outConfig, QSurface::SurfaceType *outType)
 
void q_createNativeChildrenAndSetParent (const QWidget *parentWidget)
 
static void fillRegion (QPainter *painter, const QRegion &rgn, const QBrush &brush)
 
static void applyCursor (QWidget *w, const QCursor &c)
 
static void unsetCursor (QWidget *w)
 
void qt_qpa_set_cursor (QWidget *w, bool force)
 
static void sendResizeEvents (QWidget *target)
 
QString qt_setWindowTitle_helperHelper (const QString &title, const QWidget *widget)
 Returns a modified window title with the [*] place holder replaced according to the rules described in QWidget::setWindowTitle.
 
static bool isEmbedded (const QWindow *w)
 
void qSendWindowChangeToTextureChildrenRecursively (QWidget *widget, QEvent::Type eventType)
 
static void setAttribute_internal (Qt::WidgetAttribute attribute, bool on, QWidgetData *data, QWidgetPrivate *d)
 
Q_WIDGETS_EXPORT QWidgetDataqt_qwidget_data (QWidget *widget)
 
Q_WIDGETS_EXPORT QWidgetPrivateqt_widget_private (QWidget *widget)
 
static bool canMapPosition (QWindow *window)
 
static MapToGlobalTransformResult mapToGlobalTransform (const QWidget *w)
 
static QWindowgrabberWindow (const QWidget *w)
 
static void grabMouseForWidget (QWidget *widget, const QCursor *cursor=nullptr)
 
static void releaseMouseGrabOfWidget (QWidget *widget)
 
QDebug operator<< (QDebug debug, const QWidget *widget)
 
QWidgetList focusPath (QWidget *from, QWidget *to, QWidgetPrivate::FocusDirection direction)
 

Variables

QWidgetqt_button_down
 
QWidgetqt_pressGrab = nullptr
 
QWidgetqt_mouseGrb = nullptr
 
static bool mouseGrabWithCursor = false
 
static QWidgetkeyboardGrb = nullptr
 

Macro Definition Documentation

◆ FOCUS_NEXT

◆ FOCUS_PREV

Function Documentation

◆ applyCursor()

static void applyCursor ( QWidget * w,
const QCursor & c )
inlinestatic

Definition at line 5002 of file qwidget.cpp.

References window().

+ Here is the call graph for this function:

◆ canMapPosition()

static bool canMapPosition ( QWindow * window)
inlinestatic

Definition at line 12539 of file qwidget.cpp.

References qt_window_private(), and window().

Referenced by mapToGlobalTransform().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fillRegion()

static void fillRegion ( QPainter * painter,
const QRegion & rgn,
const QBrush & brush )
inlinestatic

Definition at line 2223 of file qwidget.cpp.

References QRegion::boundingRect(), QPainter::device(), QPainter::drawTiledPixmap(), QPainter::fillRect(), QPaintDevice::height(), QGradient::ObjectBoundingMode, QGradient::ObjectMode, painter, Q_ASSERT, rect, QPainter::restore(), QPainter::save(), QPainter::setClipRegion(), Qt::TexturePattern, and QPaintDevice::width().

Referenced by QWidgetPrivate::paintBackground().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ focusPath()

QWidgetList focusPath ( QWidget * from,
QWidget * to,
QWidgetPrivate::FocusDirection direction )
Returns
a QWidgetList, representing the part of the focus chain, starting with
Parameters
fromand ending with
to,in

param direction.

Definition at line 13500 of file qwidget.cpp.

References direction, QWidgetPrivate::Next, QWidget::nextInFocusChain(), QWidgetPrivate::Previous, and QWidget::previousInFocusChain().

Referenced by QWidgetPrivate::takeFromFocusChain().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ grabberWindow()

static QWindow * grabberWindow ( const QWidget * w)
inlinestatic

Definition at line 12645 of file qwidget.cpp.

References QWidget::nativeParentWidget(), and window().

Referenced by QWidget::grabKeyboard(), grabMouseForWidget(), QWidget::releaseKeyboard(), releaseMouseGrabOfWidget(), QWidgetPrivate::stealKeyboardGrab(), and QWidgetPrivate::stealMouseGrab().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ grabMouseForWidget()

static void grabMouseForWidget ( QWidget * widget,
const QCursor * cursor = nullptr )
static

Definition at line 12655 of file qwidget.cpp.

References cursor, grabberWindow(), mouseGrabWithCursor, qt_mouseGrb, qt_pressGrab, QWidget::releaseMouse(), QGuiApplication::setOverrideCursor(), widget, and window().

Referenced by QWidget::grabMouse(), and QWidget::grabMouse().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isEmbedded()

static bool isEmbedded ( const QWindow * w)
inlinestatic

Definition at line 6612 of file qwidget.cpp.

Referenced by QWidgetPrivate::hide_helper(), QMenuPrivate::popup(), QWidgetPrivate::setFocus_sys(), QWidgetPrivate::show_helper(), and QQuick3DSceneRenderer::synchronize().

+ Here is the caller graph for this function:

◆ mapToGlobalTransform()

static MapToGlobalTransformResult mapToGlobalTransform ( const QWidget * w)
static

Definition at line 12560 of file qwidget.cpp.

References canMapPosition(), scene, QGraphicsScene::views(), window(), QPoint::x(), and QPoint::y().

Referenced by QWidget::mapFromGlobal(), and QWidget::mapToGlobal().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator<<()

◆ q_createNativeChildrenAndSetParent()

void q_createNativeChildrenAndSetParent ( const QWidget * parentWidget)

Definition at line 1242 of file qwidget.cpp.

References QList< T >::at(), QObject::children(), i, QWidget::internalWinId(), QObject::isWidgetType(), QWidget::isWindow(), QWidget::nativeParentWidget(), q_createNativeChildrenAndSetParent(), qobject_cast< const QWidget * >(), QList< T >::size(), QWidget::testAttribute(), Qt::WA_NativeWindow, QWidget::window(), QWidget::windowHandle(), and QWidget::winId().

Referenced by QWidgetPrivate::create(), and q_createNativeChildrenAndSetParent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ q_evaluateRhiConfig()

bool q_evaluateRhiConfig ( const QWidget * w,
QPlatformBackingStoreRhiConfig * outConfig,
QSurface::SurfaceType * outType )

Definition at line 1122 of file qwidget.cpp.

References QBackingStoreRhiSupport::checkForceRhi(), q_evaluateRhiConfigRecursive(), and qCDebug.

Referenced by QWidgetWindow::QWidgetWindow(), QWidgetPrivate::create(), and QWidget::setParent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ q_evaluateRhiConfigRecursive()

static bool q_evaluateRhiConfigRecursive ( const QWidget * w,
QPlatformBackingStoreRhiConfig * outConfig,
QSurface::SurfaceType * outType )
static

Definition at line 1103 of file qwidget.cpp.

References child, QWidgetPrivate::get(), q_evaluateRhiConfigRecursive(), and QBackingStoreRhiSupport::surfaceTypeForConfig().

Referenced by q_evaluateRhiConfig(), and q_evaluateRhiConfigRecursive().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Q_LOGGING_CATEGORY() [1/3]

Q_LOGGING_CATEGORY ( lcWidgetPainting ,
"qt.widgets.painting" ,
QtWarningMsg  )

◆ Q_LOGGING_CATEGORY() [2/3]

Q_LOGGING_CATEGORY ( lcWidgetShowHide ,
"qt.widgets.showhide" ,
QtWarningMsg  )

◆ Q_LOGGING_CATEGORY() [3/3]

Q_LOGGING_CATEGORY ( lcWidgetWindow ,
"qt.widgets.window" ,
QtWarningMsg  )

References widget.

◆ qRectIntersects()

static bool qRectIntersects ( const QRect & r1,
const QRect & r2 )
inlinestatic

Definition at line 97 of file qwidget.cpp.

References QRect::bottom(), QRect::left(), qMax(), qMin(), r1, r2, QRect::right(), and QRect::top().

Referenced by QWidgetPrivate::clipRegion(), QWidgetPrivate::overlappedRegion(), QWidgetPrivate::paintSiblingsRecursive(), and QWidgetPrivate::subtractOpaqueSiblings().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qSendWindowChangeToTextureChildrenRecursively()

void qSendWindowChangeToTextureChildrenRecursively ( QWidget * widget,
QEvent::Type eventType )

Definition at line 10613 of file qwidget.cpp.

References d, QWidgetPrivate::Direct, QWidgetPrivate::get(), i, qobject_cast< QWidget * >(), qSendWindowChangeToTextureChildrenRecursively(), QCoreApplication::sendEvent(), widget, and window().

Referenced by qSendWindowChangeToTextureChildrenRecursively(), and QWidget::setParent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qt_qpa_set_cursor()

void qt_qpa_set_cursor ( QWidget * w,
bool force )

Definition at line 5014 of file qwidget.cpp.

Referenced by QApplicationPrivate::dispatchEnterLeave(), QWidgetPrivate::setCursor_sys(), QWidgetPrivate::setEnabled_helper(), QWidgetPrivate::show_sys(), and QWidgetPrivate::unsetCursor_sys().

+ Here is the caller graph for this function:

◆ qt_qwidget_data()

Q_WIDGETS_EXPORT QWidgetData * qt_qwidget_data ( QWidget * widget)

Definition at line 12383 of file qwidget.cpp.

◆ qt_sendSpontaneousEvent()

bool qt_sendSpontaneousEvent ( QObject * ,
QEvent *  )
related

◆ qt_setWindowTitle_helperHelper()

QString qt_setWindowTitle_helperHelper ( const QString & title,
const QWidget * widget )

Returns a modified window title with the [*] place holder replaced according to the rules described in QWidget::setWindowTitle.

This function assumes that "[*]" can be quoted by another "[*]", so it will replace two place holders by one and a single last one by either "*" or nothing depending on the modified flag.

Definition at line 5992 of file qwidget.cpp.

References QString::indexOf(), QWidget::isWindowModified(), Q_ASSERT, QStyle::SH_TitleBar_ModifyNotification, QWidget::style(), QStyle::styleHint(), title, and widget.

Referenced by QDockWidget::changeEvent(), QDockWidgetPrivate::init(), QWidgetPrivate::setWindowIconText_helper(), QWidgetPrivate::setWindowTitle_helper(), tabTextFor(), and QMdiSubWindowPrivate::updateInternalWindowTitle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qt_widget_private()

◆ releaseMouseGrabOfWidget()

static void releaseMouseGrabOfWidget ( QWidget * widget)
static

Definition at line 12678 of file qwidget.cpp.

References grabberWindow(), mouseGrabWithCursor, qt_mouseGrb, QGuiApplication::restoreOverrideCursor(), widget, and window().

Referenced by QWidget::releaseMouse().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendResizeEvents()

static void sendResizeEvents ( QWidget * target)
static

Definition at line 5188 of file qwidget.cpp.

References QList< T >::at(), child, i, QObject::isWidgetType(), QCoreApplication::sendEvent(), sendResizeEvents(), QList< T >::size(), and Qt::WA_PendingResizeEvent.

Referenced by QWidget::grab(), and sendResizeEvents().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAttribute_internal()

static void setAttribute_internal ( Qt::WidgetAttribute attribute,
bool on,
QWidgetData * data,
QWidgetPrivate * d )
static

This just sets the corresponding attribute bit to 1 or 0

Definition at line 11241 of file qwidget.cpp.

References d.

Referenced by QWidget::setAttribute().

+ Here is the caller graph for this function:

◆ unsetCursor()

static void unsetCursor ( QWidget * w)
inlinestatic

Definition at line 5008 of file qwidget.cpp.

References window().

+ Here is the call graph for this function:

Variable Documentation

◆ keyboardGrb

QWidget* keyboardGrb = nullptr
static

◆ mouseGrabWithCursor

bool mouseGrabWithCursor = false
static

Definition at line 12642 of file qwidget.cpp.

Referenced by grabMouseForWidget(), and releaseMouseGrabOfWidget().

◆ qt_button_down

QWidget* qt_button_down
extern

Definition at line 26 of file qwidgetwindow.cpp.

◆ qt_mouseGrb

QWidget* qt_mouseGrb = nullptr

◆ qt_pressGrab

QWidget* qt_pressGrab = nullptr

Definition at line 12640 of file qwidget.cpp.

Referenced by grabMouseForWidget(), and QWidget::mouseGrabber().