9#include "private/qduplicatetracker_p.h"
25#if QT_CONFIG(accessibility)
28#include <qpa/qplatformwindow.h>
29#include <qpa/qplatformwindow_p.h>
30#include "private/qwidgetwindow_p.h"
35#if QT_CONFIG(whatsthis)
39#include "private/qstylesheetstyle_p.h"
40#include "private/qstyle_p.h"
43#include <QtGui/private/qhighdpiscaling_p.h>
44#include <QtGui/qinputmethod.h>
46#if QT_CONFIG(graphicseffect)
47#include <private/qgraphicseffect_p.h>
50#include <private/qwidgetrepaintmanager_p.h>
51#include <private/qpaintengine_raster_p.h>
54#include <QtGui/private/qwindow_p.h>
56# include "QtGui/private/qaction_p.h"
59#if QT_CONFIG(graphicsview)
60#include "QtWidgets/qgraphicsproxywidget.h"
61#include "QtWidgets/qgraphicsscene.h"
62#include "private/qgraphicsproxywidget_p.h"
64#include "QtWidgets/qabstractscrollarea.h"
65#include "private/qabstractscrollarea_p.h"
66#include "private/qevent_p.h"
68#include "private/qgesturemanager_p.h"
70#ifdef QT_KEYPAD_NAVIGATION
71#if QT_CONFIG(tabwidget)
90#ifndef QT_NO_DEBUG_STREAM
117#
if !defined(QT_NO_IM)
118 , imHints(
Qt::ImhNone)
121 , toolTipDuration(-1)
123 , directFontResolveMask(0)
124 , inheritedFontResolveMask(0)
125 , directPaletteResolveMask(0)
126 , inheritedPaletteResolveMask(0)
131 , leftLayoutItemMargin(0)
132 , topLayoutItemMargin(0)
133 , rightLayoutItemMargin(0)
134 , bottomLayoutItemMargin(0)
139 , dirtyOpaqueChildren(1)
141 , retainSizeWhenHiddenChanged(0)
145 , usesDoubleBufferedGLContext(0)
146 , mustHaveWindowHandle(0)
148 , textureChildSeen(0)
150 , inheritsInputMethodHints(0)
152 , renderToTextureReallyDirty(1)
154 , childrenHiddenByWState(0)
155 , childrenShownByExpose(0)
161 qFatal(
"QWidget: Must construct a QApplication before a QWidget");
165#ifdef QT_BUILD_INTERNAL
171 qFatal(
"Cannot mix incompatible Qt library (version 0x%x) with this library (version 0x%x)",
178#ifdef QWIDGET_EXTRA_DEBUG
179 static int count = 0;
200 if (
q->children().size() > 0) {
203 for (
int i = 0;
i < childObjects.
size(); ++
i) {
205 if (
w && !
w->isWindow()) {
210 w->d_func()->setWSGeometry();
211 w->d_func()->setDirtyOpaqueRegion();
232 t.translate(
p.x(),
p.y());
239#ifdef QT_KEYPAD_NAVIGATION
240QPointer<QWidget> QWidgetPrivate::editingWidget;
249bool QWidget::hasEditFocus()
const
252 while (
w->d_func()->extra &&
w->d_func()->extra->focus_proxy)
253 w =
w->d_func()->extra->focus_proxy;
254 return QWidgetPrivate::editingWidget ==
w;
269void QWidget::setEditFocus(
bool on)
272 while (
f->d_func()->extra &&
f->d_func()->extra->focus_proxy)
273 f =
f->d_func()->extra->focus_proxy;
275 if (QWidgetPrivate::editingWidget && QWidgetPrivate::editingWidget !=
f)
276 QWidgetPrivate::editingWidget->setEditFocus(
false);
278 if (on && !
f->hasFocus())
281 if ((!on && !QWidgetPrivate::editingWidget)
282 || (on && QWidgetPrivate::editingWidget ==
f)) {
286 if (!on && QWidgetPrivate::editingWidget ==
f) {
287 QWidgetPrivate::editingWidget = 0;
292 QWidgetPrivate::editingWidget =
f;
327 return d->extra &&
d->extra->autoFillBackground;
335 if (
d->extra->autoFillBackground ==
enabled)
338 d->extra->autoFillBackground =
enabled;
818#ifdef QT_NO_EXCEPTIONS
823 d->removeFromFocusChain();
946 qFatal(
"QWidget: Cannot create a QWidget without QApplication");
957 "Widgets must be created in the GUI thread.");
961 data.fstrut_dirty =
true;
964 data.widget_attributes = 0;
965 data.window_flags =
f;
966 data.window_state = 0;
967 data.focus_policy = 0;
971 data.sizehint_forced = 0;
972 data.is_closing =
false;
974 data.in_set_window_state = 0;
975 data.in_destructor =
false;
990 data.crect = parentWidget ?
QRect(0,0,100,30) :
QRect(0,0,640,480);
995 else if (parentWidget)
996 q->setParent(parentWidget,
data.window_flags);
1022 q->create(0,
true,
true);
1026 child->d_func()->createRecursively();
1033 if (
auto *backingStore =
q->backingStore()) {
1035 return backingStore->handle()->rhi(
window);
1068 if (
auto nativeParent = q_func()->nativeParentWidget()) {
1069 if (
auto window = nativeParent->windowHandle())
1074 if (
auto topLevel = q_func()->topLevelWidget()) {
1095#if QT_CONFIG(graphicsview)
1097 if (nearestGraphicsProxyWidget(q_func()))
1109 if (
config.isEnabled()) {
1117 if (
const QWidget *childWidget = qobject_cast<const QWidget *>(
child)) {
1139 qCDebug(lcWidgetPainting) <<
"Tree with root" <<
w <<
"evaluated to forced flushing with QRhi";
1146 qCDebug(lcWidgetPainting) <<
"Tree with root" <<
w <<
"evaluates to flushing with QRhi";
1173 qWarning(
"QWidget::create(): Parameter 'window' does not have any effect.");
1177 if (
d->data.in_destructor)
1181 Qt::WindowFlags &
flags =
data->window_flags;
1207 if (paintOnScreenEnv)
1213 d->updateIsOpaque();
1229 d->setWindowIcon_sys();
1231 if (
isWindow() && !
d->topData()->iconText.isEmpty())
1232 d->setWindowIconText_helper(
d->topData()->iconText);
1233 if (
isWindow() && !
d->topData()->caption.isEmpty())
1234 d->setWindowTitle_helper(
d->topData()->caption);
1235 if (
isWindow() && !
d->topData()->filePath.isEmpty())
1236 d->setWindowFilePath_helper(
d->topData()->filePath);
1238 d->updateSystemBackground();
1241 d->setWindowIcon_sys();
1249 d->updateFrameStrut();
1255 for (
int i = 0;
i < children.
size();
i++) {
1261 childWidget->
winId();
1295 for (
const QByteArray &propertyName : dynamicPropertyNames) {
1296 if (!
qstrncmp(propertyName,
"_q_platform_", 12))
1300 Qt::WindowFlags &
flags =
data.window_flags;
1302#if defined(QT_PLATFORM_UIKIT)
1318 if (
win->isTopLevel()) {
1321 if (!targetScreen) {
1323 ?
q->screen() :
nullptr;
1331 format.setAlphaBufferSize(8);
1336 if (nativeParent->windowHandle()) {
1338 win->setTransientParent(nativeParent->window()->windowHandle());
1341 win->setTransientParent(
nullptr);
1354 platformWindow->setFrameStrutEventsEnabled(
true);
1357 data.window_flags =
win->flags();
1360 if (!
topData()->role.isNull()) {
1361 if (
auto *xcbWindow =
dynamic_cast<QXcbWindow*
>(
win->handle()))
1372 if (!store &&
q->isWindow())
1386 if (
win->handle()) {
1400 if (
data.crect.width() == 0 ||
data.crect.height() == 0) {
1402 }
else if (
q->isVisible()) {
1404 win->setNativeWindowVisibility(
true);
1409static const char activeXNativeParentHandleProperty[] =
"_q_embedded_native_parent_handle";
1421 if (
extra->topextra->opacity != 255 &&
q->isWindow())
1424 const bool isTipLabel =
q->inherits(
"QTipLabel");
1425 const bool isAlphaWidget = !isTipLabel &&
q->inherits(
"QAlphaWidget");
1428 const QVariant activeXNativeParentHandle =
q->property(activeXNativeParentHandleProperty);
1429 if (activeXNativeParentHandle.isValid())
1430 extra->topextra->window->setProperty(activeXNativeParentHandleProperty, activeXNativeParentHandle);
1431 if (isTipLabel || isAlphaWidget)
1432 extra->topextra->window->setProperty(
"_q_windowsDropShadow",
QVariant(
true));
1434 if (isTipLabel || isAlphaWidget ||
q->inherits(
"QRollEffect"))
1452 d->data.in_destructor =
true;
1454#if defined (QT_CHECK_STATE)
1459#ifndef QT_NO_GESTURES
1462 for (
auto it =
d->gestureContext.keyBegin(),
end =
d->gestureContext.keyEnd();
it !=
end; ++
it)
1463 manager->cleanupCachedGestures(
this, *
it);
1465 d->gestureContext.clear();
1470 for (
auto action : std::as_const(
d->actions)) {
1477#ifndef QT_NO_SHORTCUT
1486 d->layout =
nullptr;
1492#if QT_CONFIG(graphicsview)
1494 while (
w->d_func()->extra &&
w->d_func()->extra->focus_proxy)
1495 w =
w->d_func()->extra->focus_proxy;
1498 if (!e || !e->proxyWidget || (
w->parentWidget() &&
w->parentWidget()->d_func()->focus_child ==
this))
1505 d->setDirtyOpaqueRegion();
1519 qApp->d_func()->sendSyntheticEnterLeave(
this);
1523 repaintManager->removeDirtyWidget(
this);
1525 repaintManager->removeStaticWidget(
this);
1528 delete d->needsFlush;
1529 d->needsFlush =
nullptr;
1533 bool blocked =
d->blockSig;
1536 if (
d->isSignalConnected(0)) {
1542 qWarning(
"Detected an unexpected exception in ~QWidget while emitting destroyed().");
1547 if (
d->declarativeData) {
1548 d->wasDeleted =
true;
1551 d->declarativeData =
nullptr;
1552 d->wasDeleted =
false;
1555 d->blockSig = blocked;
1557 if (!
d->children.isEmpty())
1558 d->deleteChildren();
1575 }
QT_CATCH(
const std::exception&) {
1579#if QT_CONFIG(graphicseffect)
1580 delete d->graphicsEffect;
1583 d->isWidget =
false;
1596 const WId oldWinId =
data.winid;
1603 if (oldWinId !=
id) {
1613 if (!
extra->topextra) {
1614 extra->topextra = std::make_unique<QTLWExtra>();
1617 x->sharedPainter =
nullptr;
1618 x->incw =
x->inch = 0;
1619 x->basew =
x->baseh = 0;
1620 x->frameStrut.setCoords(0, 0, 0, 0);
1621 x->normalGeometry =
QRect(0,0,-1,-1);
1622 x->savedFlags = { };
1624 x->posIncludesFrame = 0;
1625 x->sizeAdjusted =
false;
1627 x->window =
nullptr;
1628 x->initialScreen =
nullptr;
1630#ifdef QWIDGET_EXTRA_DEBUG
1631 static int count = 0;
1645 extra = std::make_unique<QWExtra>();
1646 extra->glContext =
nullptr;
1647#if QT_CONFIG(graphicsview)
1648 extra->proxyWidget =
nullptr;
1654 extra->customDpiX = 0;
1655 extra->customDpiY = 0;
1656 extra->explicitMinSize = 0;
1657 extra->explicitMaxSize = 0;
1658 extra->autoFillBackground = 0;
1659 extra->nativeChildrenForced = 0;
1660 extra->inRenderWithPainter = 0;
1661 extra->hasWindowContainer =
false;
1664#ifdef QWIDGET_EXTRA_DEBUG
1665 static int count = 0;
1684#ifndef QT_NO_STYLE_STYLESHEET
1689 if (
extra->topextra)
1705 if (
extra->hasWindowContainer)
1708 delete extra->topextra->window;
1709 extra->topextra->window =
nullptr;
1736 above = (sibling ==
w);
1740 const QRect siblingRect = sibling->d_func()->effectiveRectFor(sibling->data->crect);
1742 const auto &siblingExtra = sibling->d_func()->extra;
1743 if (siblingExtra && siblingExtra->hasMask && !sibling->d_func()->graphicsEffect
1748 if (breakAfterFirst)
1752 w =
w->parentWidget();
1765 repaintManager->sync();
1774 repaintManager->sync(q_func(), region);
1780 if (
data.in_destructor)
1790 extra->staticContentsSize =
data.crect.size();
1801 QRegion toBePainted(noPartialUpdateSupport ?
q->rect() : rgn);
1805 if (toBePainted.isEmpty())
1811 qWarning(
"QWidget::repaint: It is dangerous to leave painters active on a widget outside of the PaintEvent");
1818 if (
enable && !
q->isWindow() &&
q->parentWidget() && !
q->parentWidget()->updatesEnabled())
1831 if (
w && !
w->isWindow() && !
w->testAttribute(
attribute))
1832 w->d_func()->setUpdatesEnabled_helper(
enable);
1847#if QT_CONFIG(graphicsview)
1848 if (!
q->parentWidget() &&
extra &&
extra->proxyWidget) {
1860 const bool useStyleSheetPropagationInWidgetStyles =
1883 if (!
w->isVisible())
1891 &&
w->parentWidget()) {
1894 w =
w->parentWidget();
1895 r &=
QRect(ox, oy,
w->width(),
w->height());
1906 if (!
q->isVisible())
1916 &&
w->parentWidget()) {
1920 w =
w->parentWidget();
1921 r &=
QRegion(ox, oy,
w->width(),
w->height());
1924 while(
w->d_func()->children.at(
i++) !=
static_cast<const QObject *
>(ignoreUpTo))
1927 if (
QWidget *sibling = qobject_cast<QWidget *>(
w->d_func()->children.at(
i))) {
1928 if (sibling->isVisible() && !sibling->isWindow()) {
1929 QRect siblingRect(ox+sibling->x(), oy+sibling->y(),
1930 sibling->width(), sibling->height());
1944 scaleTransform.
scale(devicePixelRatio, devicePixelRatio);
1946 paintEngine->d_func()->baseSystemClip = region;
1947 paintEngine->d_func()->setSystemTransform(scaleTransform);
1951#if QT_CONFIG(graphicseffect)
1952void QWidgetPrivate::invalidateGraphicsEffectsRecursively()
1957 if (
w->graphicsEffect()) {
1958 QWidgetEffectSourcePrivate *sourced =
1959 static_cast<QWidgetEffectSourcePrivate *
>(
w->graphicsEffect()->source()->d_func());
1960 if (!sourced->updateDueToGraphicsEffect)
1961 w->graphicsEffect()->source()->d_func()->invalidateCache();
1974#if QT_CONFIG(graphicseffect)
1975 invalidateGraphicsEffectsRecursively();
2006 QRegion r = childd->isOpaque ?
child->rect() : childd->getOpaqueChildren();
2007 if (childd->extra && childd->extra->hasMask)
2008 r &= childd->extra->mask;
2012 that->opaqueChildren +=
r;
2015 that->opaqueChildren &= q_func()->rect();
2016 that->dirtyOpaqueChildren =
false;
2018 return that->opaqueChildren;
2033 bool alsoNonOpaque)
const
2037 if (disableSubtractOpaqueSiblings ||
q->isWindow())
2040 QRect clipBoundingRect;
2041 bool dirtyClipBoundingRect =
true;
2044 bool dirtyParentClip =
true;
2055 const QRect widgetGeometry =
w->d_func()->effectiveRectFor(
w->data->crect);
2061 const QRect siblingGeometry = sibling->d_func()->effectiveRectFor(sibling->data->crect);
2065 if (dirtyClipBoundingRect) {
2066 clipBoundingRect = sourceRegion.boundingRect();
2067 dirtyClipBoundingRect =
false;
2073 if (dirtyParentClip) {
2074 parentClip = sourceRegion.
translated(parentOffset);
2075 dirtyParentClip =
false;
2078 const QPoint siblingPos(sibling->data->crect.topLeft());
2079 const QRect siblingClipRect(sibling->d_func()->clipRect());
2080 QRegion siblingDirty(parentClip);
2081 siblingDirty &= (siblingClipRect.translated(siblingPos));
2082 const bool hasMask = sibling->d_func()->extra && sibling->d_func()->extra->hasMask
2083 && !sibling->d_func()->graphicsEffect;
2085 siblingDirty &= sibling->d_func()->extra->
mask.
translated(siblingPos);
2086 if (siblingDirty.isEmpty())
2089 if (sibling->d_func()->isOpaque || alsoNonOpaque) {
2092 sourceRegion -= siblingDirty;
2094 sourceRegion -= siblingGeometry.translated(-parentOffset);
2097 if (hasDirtySiblingsAbove)
2098 *hasDirtySiblingsAbove =
true;
2101 QRegion opaqueSiblingChildren(sibling->d_func()->getOpaqueChildren());
2102 opaqueSiblingChildren.translate(-parentOffset + siblingPos);
2103 sourceRegion -= opaqueSiblingChildren;
2105 if (sourceRegion.isEmpty())
2108 dirtyClipBoundingRect =
true;
2109 dirtyParentClip =
true;
2112 w =
w->parentWidget();
2114 dirtyParentClip =
true;
2125#if QT_CONFIG(graphicseffect)
2127 w =
q->parentWidget();
2139 w =
w->parentWidget();
2145#if defined(QT_NO_BACKINGSTORE)
2163#if QT_CONFIG(graphicseffect)
2179 if (
q->autoFillBackground()) {
2180 const QBrush &autoFillBrush = pal.
brush(
q->backgroundRole());
2181 if (autoFillBrush.style() !=
Qt::NoBrush && autoFillBrush.isOpaque()) {
2189 if (windowBrush.style() !=
Qt::NoBrush && windowBrush.isOpaque()) {
2210 const int oldAlpha =
format.alphaBufferSize();
2212 if (oldAlpha != newAlpha) {
2230 format.setAlphaBufferSize(newAlpha);
2245 }
else if (
brush.gradient()
2260#if QT_CONFIG(scrollarea)
2265 QAbstractScrollArea *
scrollArea = qobject_cast<QAbstractScrollArea *>(
parent);
2268 QAbstractScrollAreaPrivate *
priv =
static_cast<QAbstractScrollAreaPrivate *
>(scrollPrivate);
2279 bool brushOriginSet =
false;
2280 const QBrush autoFillBrush =
q->palette().brush(
q->backgroundRole());
2282 if ((
flags &
DrawAsRoot) && !(
q->autoFillBackground() && autoFillBrush.isOpaque())) {
2284 if (!brushOriginSet)
2297 if (
q->autoFillBackground()) {
2298 if (!brushOriginSet)
2373 if (!
data->in_destructor
2378 that->d_func()->createWinId();
2379 return that->data->winid;
2390 if (!
q->isWindow()) {
2395 if (!
parent->internalWinId()) {
2437 if (!
screen || !
q->isWindow())
2440 if (currentScreen !=
screen) {
2482 return realParent->internalWinId();
2500 return d->windowHandle();
2513 if (
auto associatedScreen =
d->associatedScreen())
2514 return associatedScreen;
2515 if (
auto topLevel =
window()) {
2517 if (topData->initialScreen)
2518 return topData->initialScreen;
2544#ifndef QT_NO_STYLE_STYLESHEET
2566 return d->extra->styleSheet;
2572 if (
data->in_destructor)
2587 bool repolish =
d->polished;
2589 const auto childWidgets = findChildren<QWidget*>();
2590 for (
auto child : childWidgets) {
2591 repolish =
child->d_func()->polished;
2597 proxy->repolish(
this);
2618 if (
d->extra &&
d->extra->style)
2619 return d->extra->style;
2649#ifndef QT_NO_STYLE_STYLESHEET
2653 styleSheetStyle->ref();
2654 d->setStyle_helper(
style,
false);
2660 d->setStyle_helper(
style,
false);
2666 QStyle *oldStyle =
q->style();
2670#ifndef QT_NO_STYLE_STYLESHEET
2671 QPointer<QStyle> origStyle =
extra->style;
2673 extra->style = newStyle;
2677 oldStyle->unpolish(
q);
2678 q->style()->polish(
q);
2684 for (
int i = 0;
i < childrenList.size(); ++
i) {
2687 c->d_func()->inheritStyle();
2691#ifndef QT_NO_STYLE_STYLESHEET
2694 cssStyle->clearWidgetFont(
q);
2702#ifndef QT_NO_STYLE_STYLESHEET
2712#ifndef QT_NO_STYLE_STYLESHEET
2719 if (!
q->styleSheet().isEmpty()) {
2731 QStyle *newStyle = parentStyle;
2735 newStyle = styleSheetStyle;
2745 if (origStyle == extraStyle)
2752 origStyle =
nullptr;
2826 if (
q->windowHandle())
2827 q->windowHandle()->setModality(
q->windowModality());
2906 return Qt::WindowStates(
data->window_state);
2919 data->window_state = newstate;
2959 if (oldstate == newstate)
2964 data->window_state = newstate;
2965 data->in_set_window_state = 1;
2973 d->topData()->normalGeometry =
geometry();
2978 data->in_set_window_state = 0;
3044#if !defined Q_OS_QNX
3111 &&
w->parentWidget()
3112 &&
w->parentWidget() != ancestor)
3161 qWarning(
"QWidget::insertAction: Attempt to insert null action");
3166 if (
d->actions.contains(action))
3169 int pos =
d->actions.indexOf(before);
3172 pos =
d->actions.size();
3174 d->actions.insert(
pos, action);
3212 if (
d->actions.removeAll(action)) {
3259#if QT_CONFIG(shortcut)
3302 const QObject *receiver,
const char* member,
3310#if QT_CONFIG(shortcut)
3312 const QObject *receiver,
const char* member,
3321 const QObject *receiver,
const char* member,
3385 if (
enable && !
q->isWindow() &&
q->parentWidget() && !
q->parentWidget()->isEnabled())
3394 if (!
enable &&
q->window()->focusWidget() ==
q) {
3395 bool parentIsEnabled = (!
q->parentWidget() ||
q->parentWidget()->isEnabled());
3396 if (!parentIsEnabled || !
q->focusNextChild())
3404 w->d_func()->setEnabled_helper(
enable);
3488 QRect fs =
d->frameStrut();
3514 return data->crect.x() -
d->frameStrut().left();
3515 return data->crect.x();
3534 return data->crect.y() -
d->frameStrut().top();
3535 return data->crect.y();
3570 if (!
d->maybeTopData() || !
d->maybeTopData()->posIncludesFrame)
3571 result -=
d->frameStrut().topLeft();
3693 return d->topData()->normalGeometry;
3713 for (
int i = 0;
i <
d->children.size(); ++
i) {
3715 if (
w && !
w->isWindow() && !
w->isHidden())
3737 for (
int i = 0;
i <
d->children.size(); ++
i) {
3739 if (
w && !
w->isWindow() && !
w->isHidden()) {
3771 return d->extra ?
QSize(
d->extra->minw,
d->extra->minh) :
QSize(0, 0);
3793 return d->extra ?
QSize(
d->extra->maxw,
d->extra->maxh)
3872 return (
d->extra &&
d->extra->topextra)
3873 ?
QSize(
d->extra->topextra->incw,
d->extra->topextra->inch)
3893 return (
d->extra &&
d->extra->topextra)
3894 ?
QSize(
d->extra->topextra->basew,
d->extra->topextra->baseh)
3902 int mw = minw, mh = minh;
3908 qWarning(
"QWidget::setMinimumSize: (%s/%s) "
3909 "The largest allowed size is (%d,%d)",
3910 q->objectName().toLocal8Bit().data(),
q->metaObject()->className(),
QWIDGETSIZE_MAX,
3916 qWarning(
"QWidget::setMinimumSize: (%s/%s) Negative sizes (%d,%d) "
3918 q->objectName().toLocal8Bit().data(),
q->metaObject()->className(), minw, minh);
3919 minw = mw =
qMax(minw, 0);
3920 minh = mh =
qMax(minh, 0);
3934 if (
extra &&
q->windowHandle()) {
3941 if (
extra->topextra) {
3942 winp->baseSize =
QSize(
extra->topextra->basew,
extra->topextra->baseh);
3943 winp->sizeIncrement =
QSize(
extra->topextra->incw,
extra->topextra->inch);
3946 if (winp->platformWindow) {
3948 winp->platformWindow->propagateSizeHints();
3964 if (!
d->setMinimumSize_helper(minw, minh))
3968 d->setConstraints_sys();
3977#if QT_CONFIG(graphicsview)
3979 if (
d->extra->proxyWidget)
3980 d->extra->proxyWidget->setMinimumSize(minw, minh);
3983 d->updateGeometry_helper(
d->extra->minw ==
d->extra->maxw &&
d->extra->minh ==
d->extra->maxh);
3990 qWarning(
"QWidget::setMaximumSize: (%s/%s) "
3991 "The largest allowed size is (%d,%d)",
3992 q->objectName().toLocal8Bit().data(),
q->metaObject()->className(),
QWIDGETSIZE_MAX,
3998 qWarning(
"QWidget::setMaximumSize: (%s/%s) Negative sizes (%d,%d) "
4000 q->objectName().toLocal8Bit().data(),
q->metaObject()->className(), maxw, maxh);
4001 maxw =
qMax(maxw, 0);
4002 maxh =
qMax(maxh, 0);
4005 if (
extra->maxw == maxw &&
extra->maxh == maxh)
4024 if (!
d->setMaximumSize_helper(maxw, maxh))
4028 d->setConstraints_sys();
4035#if QT_CONFIG(graphicsview)
4037 if (
d->extra->proxyWidget)
4038 d->extra->proxyWidget->setMaximumSize(maxw, maxh);
4042 d->updateGeometry_helper(
d->extra->minw ==
d->extra->maxw &&
d->extra->minh ==
d->extra->maxh);
4056 if (
x->incw ==
w &&
x->inch ==
h)
4061 d->setConstraints_sys();
4075 if (
x->basew == basew &&
x->baseh == baseh)
4080 d->setConstraints_sys();
4114 bool minSizeSet =
d->setMinimumSize_helper(
w,
h);
4115 bool maxSizeSet =
d->setMaximumSize_helper(
w,
h);
4116 if (!minSizeSet && !maxSizeSet)
4120 d->setConstraints_sys();
4122 d->updateGeometry_helper(
true);
4134 d->extra->explicitMinSize = expl;
4143 d->extra->explicitMinSize = expl;
4152 d->extra->explicitMaxSize = expl;
4161 d->extra->explicitMaxSize = expl;
4179 d->extra->explicitMinSize = explMin;
4180 d->extra->explicitMaxSize = explMax;
4199 d->extra->explicitMinSize = explMin;
4200 d->extra->explicitMaxSize = explMax;
4219 Q_ASSERT_X(
w,
"QWidget::mapTo(const QWidget *parent, const QPointF &pos)",
4220 "parent must be in parent hierarchy");
4221 p =
w->mapToParent(
p);
4222 w =
w->parentWidget();
4251 Q_ASSERT_X(
w,
"QWidget::mapFrom(const QWidget *parent, const QPoint &pos)",
4252 "parent must be in parent hierarchy");
4254 p =
w->mapFromParent(
p);
4255 w =
w->parentWidget();
4289 return pos +
data->crect.topLeft();
4312 return pos -
data->crect.topLeft();
4333 while (!
w->isWindow() &&
p) {
4411 d->updateSystemBackground();
4412 d->propagatePaletteChange();
4413 d->updateIsOpaque();
4476 d->updateSystemBackground();
4477 d->propagatePaletteChange();
4535#
if defined(Q_OS_WIN)
4555 QPalette naturalPalette =
d->naturalWidgetPalette(
d->inheritedPaletteResolveMask);
4557 d->setPalette_helper(resolvedPalette);
4573 const bool useStyleSheetPropagationInWidgetStyles =
4584 if (!
p->testAttribute(
Qt::WA_StyleSheet) || useStyleSheetPropagationInWidgetStyles) {
4586 QPalette inheritedPalette =
p->palette();
4588 naturalPalette = inheritedPalette.resolve(naturalPalette);
4590 naturalPalette =
p->palette();
4594#if QT_CONFIG(graphicsview)
4598 naturalPalette = inheritedPalette.resolve(naturalPalette);
4602 naturalPalette.setResolveMask(0);
4603 return naturalPalette;
4687#ifndef QT_NO_STYLE_STYLESHEET
4699 QFont naturalFont =
d->naturalWidgetFont(
d->inheritedFontResolveMask);
4701 d->setFont_helper(resolvedFont);
4720 const bool useStyleSheetPropagationInWidgetStyles =
4731 if (!
p->testAttribute(
Qt::WA_StyleSheet) || useStyleSheetPropagationInWidgetStyles) {
4733 if (inheritedMask != 0) {
4734 QFont inheritedFont =
p->font();
4736 naturalFont = inheritedFont.resolve(naturalFont);
4739 naturalFont =
p->font();
4743#if QT_CONFIG(graphicsview)
4745 if (inheritedMask != 0) {
4746 QFont inheritedFont =
extra->proxyWidget->font();
4748 naturalFont = inheritedFont.resolve(naturalFont);
4753 naturalFont.setResolveMask(0);
4796#ifndef QT_NO_STYLE_STYLESHEET
4799 const bool useStyleSheetPropagationInWidgetStyles =
4806#if QT_CONFIG(graphicsview)
4807 if (!
q->parentWidget() &&
extra &&
extra->proxyWidget) {
4820 data.fnt.setResolveMask(newMask);
4826#ifndef QT_NO_STYLE_STYLESHEET
4827 }
else if (!useStyleSheetPropagationInWidgetStyles &&
w->testAttribute(
Qt::WA_StyleSheet)) {
4830 cssStyle->updateStyleSheetFont(
w);
4841#ifndef QT_NO_STYLE_STYLESHEET
4842 if (!useStyleSheetPropagationInWidgetStyles && cssStyle) {
4843 cssStyle->updateStyleSheetFont(
q);
4862 w->d_func()->setLayoutDirection_helper(
direction);
4917 d->resolveLayoutDirection();
4968 return (
d->extra &&
d->extra->curs)
4980 || (
d->extra &&
d->extra->curs))
4983 d->extra->curs = std::make_unique<QCursor>(
cursor);
5003 d->extra->curs.reset();
5006 d->unsetCursor_sys();
5035 static QPointer<QWidget> lastUnderMouse =
nullptr;
5038 }
else if (lastUnderMouse) {
5039 const WId lastWinId = lastUnderMouse->effectiveWinId();
5040 const WId winId =
w->effectiveWinId();
5041 if (lastWinId && lastWinId == winId)
5043 }
else if (!
w->internalWinId()) {
5047 while (!
w->internalWinId() &&
w->parentWidget() && !
w->isWindow()
5049 w =
w->parentWidget();
5052 if (!
w->internalWinId())
5054 if (!nativeParent || !nativeParent->internalWinId())
5109 const QRegion &sourceRegion, RenderFlags renderFlags)
5112 render(&
p, targetOffset, sourceRegion, renderFlags);
5129 const QRegion &sourceRegion, RenderFlags renderFlags)
5132 qWarning(
"QWidget::render: Null pointer to painter");
5137 qWarning(
"QWidget::render: Cannot render with an inactive painter");
5146 const bool inRenderWithPainter =
d->extra &&
d->extra->inRenderWithPainter;
5147 const QRegion toBePainted = !inRenderWithPainter ?
d->prepareToRender(sourceRegion, renderFlags)
5149 if (toBePainted.isEmpty())
5154 d->extra->inRenderWithPainter =
true;
5165 d->render_helper(
painter, targetOffset, toBePainted, renderFlags);
5166 d->extra->inRenderWithPainter = inRenderWithPainter;
5171 QPainter *oldPainter =
d->sharedPainter();
5184 enginePriv->
setSystemViewport(oldSystemClip.isEmpty() ? painterClip : oldSystemClip & painterClip);
5190 d->render(
target, targetOffset, toBePainted, renderFlags);
5199 d->setSharedPainter(oldPainter);
5201 d->extra->inRenderWithPainter = inRenderWithPainter;
5210 for (
int i = 0;
i < children.
size(); ++
i) {
5239 const bool oldDirtyOpaqueChildren =
d->dirtyOpaqueChildren;
5241 if (
r.width() < 0 ||
r.height() < 0) {
5244 r =
d->prepareToRender(
QRegion(), renderFlags).boundingRect();
5248 if (!
r.intersects(
rect()))
5253 res.setDevicePixelRatio(
dpr);
5258 d->dirtyOpaqueChildren = oldDirtyOpaqueChildren;
5272#if QT_CONFIG(graphicseffect)
5276 return d->graphicsEffect;
5302#if QT_CONFIG(graphicseffect)
5306 if (
d->graphicsEffect ==
effect)
5309 if (
d->graphicsEffect) {
5310 d->invalidateBackingStore(
rect());
5311 delete d->graphicsEffect;
5312 d->graphicsEffect =
nullptr;
5324 d->updateIsOpaque();
5339 return parent ?
parent->d_func()->isAboutToShow() :
false;
5350 (
void)topLevel->d_func()->topData();
5360 hiddenWidgets.append(
widget);
5362 widget->d_func()->updateGeometry_helper(
true);
5368 if (topLevel->d_func()->
layout)
5372 QTLWExtra *topLevelExtra = topLevel->d_func()->maybeTopData();
5373 if (topLevelExtra && !topLevelExtra->sizeAdjusted
5380 topLevel->d_func()->activateChildLayoutsRecursively();
5383 for (
int i = 0;
i < hiddenWidgets.size(); ++
i) {
5390 q->window()->d_func()->sendPendingMoveAndResizeEvents(
true,
true);
5396 toBePainted &=
extra->mask;
5401 QWidget::RenderFlags renderFlags)
5408 const bool useDeviceCoordinates = originalTransform.
isScaling();
5409 if (!useDeviceCoordinates) {
5411 const QRect rect = toBePainted.boundingRect();
5418 pixmap.setDevicePixelRatio(pixmapDevicePixelRatio);
5441 const QRectF rect(toBePainted.boundingRect());
5454 q->render(&pixmapPainter,
QPoint(), toBePainted, renderFlags);
5455 pixmapPainter.end();
5472 qCInfo(lcWidgetPainting) <<
"Drawing" << rgn <<
"of" <<
q <<
"at" <<
offset
5473 <<
"into paint device" << pdev <<
"with" <<
flags;
5478#if QT_CONFIG(graphicseffect)
5481 QWidgetEffectSourcePrivate *sourced =
static_cast<QWidgetEffectSourcePrivate *
>
5483 if (!sourced->context) {
5486 sourced->context = &context;
5491 context.painter = &
p;
5497 sourced->invalidateCache();
5507 sourced->context =
nullptr;
5525 if (asRoot && !alsoInvisible)
5530 if (!toBePainted.isEmpty()) {
5531 if (!onScreen || alsoOnScreen) {
5534 qWarning(
"QWidget::repaint: Recursive repaint detected");
5545 paintEngine->d_func()->
systemRect =
q->data->crect;
5563 QColor tint =
q->palette().window().color();
5565 p.fillRect(toBePainted.boundingRect(), tint);
5572 qDebug() <<
"clipping to" << toBePainted <<
"location == " <<
offset
5573 <<
"geometry ==" <<
QRect(
q->mapTo(
q->window(),
QPoint(0, 0)),
q->size());
5576 bool skipPaintEvent =
false;
5585 }
else if (!repaintManager) {
5593 p.drawImage(
q->rect(),
img);
5594 skipPaintEvent =
true;
5600 skipPaintEvent =
true;
5603 if (!skipPaintEvent) {
5617 paintEngine->d_func()->currentClipDevice =
nullptr;
5623 qWarning(
"QWidget::repaint: It is dangerous to leave painters active on a widget outside of the PaintEvent");
5625 if (paintEngine && paintEngine->autoDestruct()) {
5628 }
else if (
q->isWindow()) {
5632 p.setClipRegion(toBePainted);
5635 p.drawTiledPixmap(
q->rect(), bg.
texture());
5637 p.fillRect(
q->rect(), bg);
5639 if (
engine->autoDestruct())
5655 QCoreApplication::sendSpontaneousEvent(
q, &e);
5662 const QRegion &sourceRegion, QWidget::RenderFlags renderFlags)
5665 qWarning(
"QWidget::render: null pointer to paint device");
5669 const bool inRenderWithPainter =
extra &&
extra->inRenderWithPainter;
5670 QRegion paintRegion = !inRenderWithPainter
5673 if (paintRegion.isEmpty())
5682 if (targetPrivate->extra && targetPrivate->extra->inRenderWithPainter) {
5683 QPainter *targetPainter = targetPrivate->sharedPainter();
5684 if (targetPainter && targetPainter->isActive())
5693 offset -= paintRegion.boundingRect().topLeft();
5694 QPoint redirectionOffset;
5702 offset -= redirectionOffset;
5705 if (!inRenderWithPainter) {
5707 const QRegion targetSystemClip = targetEngine->systemClip();
5708 if (!targetSystemClip.isEmpty())
5729 if (oldSharedPainter)
5739 bool dirtyBoundingRect =
true;
5745 if (
x && !(exludeOpaqueChildren &&
x->d_func()->isOpaque) && !
x->isHidden() && !
x->isWindow()
5746 && !(excludeNativeChildren &&
x->internalWinId())) {
5747 if (dirtyBoundingRect) {
5749 dirtyBoundingRect =
false;
5758 }
while (
index >= 0);
5764 const QPoint widgetPos(
w->data->crect.topLeft());
5769 wr -= hasMask ? wd->
extra->mask.translated(widgetPos) :
w->data->crect;
5774 if (
w->updatesEnabled()
5776 && (!
w->d_func()->extra || !
w->d_func()->extra->proxyWidget)
5783 wRegion &= wd->
extra->mask;
5788#if QT_CONFIG(graphicseffect)
5792 return m_widget->rect();
5796 qWarning(
"QGraphicsEffectSource::boundingRect: Not yet implemented, lacking device context");
5800 return context->painter->worldTransform().mapRect(m_widget->rect());
5813 toBePainted &= m_widget->rect();
5816 toBePainted &= wd->
extra->mask;
5826 if (
Q_UNLIKELY(!context && deviceCoordinates)) {
5828 qWarning(
"QGraphicsEffectSource::pixmap: Not yet implemented, lacking device context");
5833 QRectF sourceRect = m_widget->rect();
5835 if (deviceCoordinates) {
5837 sourceRect = painterTransform.mapRect(sourceRect);
5838 pixmapOffset = painterTransform.map(pixmapOffset);
5844 effectRect = m_widget->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect();
5846 effectRect = sourceRect.
adjusted(-1, -1, 1, 1).toAlignedRect();
5853 pixmapOffset -= effectRect.topLeft();
5856 if (
const auto *paintDevice =
context->painter->device())
5857 dpr = paintDevice->devicePixelRatio();
5859 qWarning(
"QWidgetEffectSourcePrivate::pixmap: Painter not active");
5869#if QT_CONFIG(graphicsview)
5881 const auto &
extra = origin->d_func()->extra;
5883 return extra->proxyWidget;
5884 return nearestGraphicsProxyWidget(origin->
parentWidget());
5988 if (
d->extra &&
d->extra->topextra) {
5989 if (!
d->extra->topextra->caption.isEmpty())
5990 return d->extra->topextra->caption;
5991 if (!
d->extra->topextra->filePath.isEmpty())
6016 const auto placeHolder =
"[*]"_L1;
6020 while (
index != -1) {
6021 index += placeHolder.size();
6025 index += placeHolder.size();
6029 int lastIndex =
cap.lastIndexOf(placeHolder,
index - 1);
6032 cap.replace(lastIndex, 3, QWidget::tr(
"*"));
6034 cap.remove(lastIndex, 3);
6040 cap.replace(
"[*][*]"_L1, placeHolder);
6059 window->setTitle(caption);
6077 if (
auto *xcbWindow =
dynamic_cast<QXcbWindow*
>(
window->handle()))
6078 xcbWindow->setWindowIconText(iconText);
6103 d->topData()->iconText = iconText;
6104 d->setWindowIconText_helper(iconText);
6126#if QT_CONFIG(accessibility)
6128 const QAccessibleInterface *accessible = QAccessible::queryAccessibleInterface(
this);
6130 oldAccessibleName = accessible->text(QAccessible::Name);
6134 d->topData()->caption =
title;
6135 d->setWindowTitle_helper(
title);
6142#if QT_CONFIG(accessibility)
6143 if (accessible && accessible->text(QAccessible::Name) != oldAccessibleName) {
6144 QAccessibleEvent
event(
this, QAccessible::NameChanged);
6145 QAccessible::updateAccessibility(&
event);
6170 if (
d->extra &&
d->extra->topextra &&
d->extra->topextra->icon)
6171 return *
d->
extra->topextra->icon;
6172 w =
w->parentWidget();
6186 if (!
q->windowHandle())
6190 if (
w && !
w->isWindow())
6211 if (!
d->extra->topextra->icon)
6212 d->extra->topextra->icon = std::make_unique<QIcon>(
icon);
6214 *
d->extra->topextra->icon =
icon;
6216 d->setWindowIcon_sys();
6217 d->setWindowIcon_helper();
6226 window->setIcon(
q->windowIcon());
6247 return (
d->extra &&
d->extra->topextra) ?
d->extra->topextra->iconText :
QString();
6277 return (
d->extra &&
d->extra->topextra) ?
d->extra->topextra->filePath :
QString();
6288 d->extra->topextra->filePath = filePath;
6289 d->setWindowFilePath_helper(filePath);
6294 if (
extra->topextra &&
extra->topextra->caption.isEmpty()) {
6315 window->setFilePath(filePath);
6327 return (
d->extra &&
d->extra->topextra) ?
d->extra->topextra->role :
QString();
6339 d->topData()->role = role;
6342 xcbWindow->setWindowRole(role);
6401 if (!
w && !
d->extra)
6414 d->extra->focus_proxy =
w;
6424 QWidget *firstChild =
nullptr;
6427 if ((firstChild = qobject_cast<QWidget *>(
child)))
6431 d->insertIntoFocusChainBefore(firstChild);
6432 }
else if (
w &&
w->isAncestorOf(
this)) {
6438 if (parentsNext ==
this) {
6442 d->QWidgetPrivate::insertIntoFocusChainAfter(
w);
6446 if (moveFocusToProxy)
6460 return d->extra ?
d->extra->focus_proxy.data() :
nullptr;
6479 while (
w->d_func()->extra &&
w->d_func()->extra->focus_proxy)
6480 w =
w->d_func()->extra->focus_proxy;
6481#if QT_CONFIG(graphicsview)
6483 const auto &e =
window->d_func()->extra;
6531 QWidget *
f = d_func()->deepestFocusProxy();
6538#if QT_CONFIG(graphicsview)
6539 QWidget *previousProxyFocus =
nullptr;
6540 if (
const auto &topData =
window()->d_func()->extra) {
6541 if (topData->proxyWidget && topData->proxyWidget->hasFocus()) {
6542 previousProxyFocus = topData->proxyWidget->widget()->
focusWidget();
6543 if (previousProxyFocus && previousProxyFocus->focusProxy())
6544 previousProxyFocus = previousProxyFocus->
focusProxy();
6545 if (previousProxyFocus ==
f && !topData->proxyWidget->d_func()->proxyIsGivingFocus)
6551#if QT_CONFIG(graphicsview)
6553 if (
const auto &topData =
window()->d_func()->extra) {
6554 if (topData->proxyWidget && !topData->proxyWidget->hasFocus()) {
6555 f->d_func()->updateFocusChild();
6556 topData->proxyWidget->d_func()->focusFromWidgetToProxy = 1;
6557 topData->proxyWidget->
setFocus(reason);
6558 topData->proxyWidget->d_func()->focusFromWidgetToProxy = 0;
6563 if (
f->isActiveWindow()) {
6577 f->d_func()->updateFocusChild();
6580#if QT_CONFIG(accessibility)
6582 if (!(
f->inherits(
"QMenuBar") ||
f->inherits(
"QMenu") ||
f->inherits(
"QMenuItem")))
6584 QAccessibleEvent
event(
f, QAccessible::Focus);
6585 QAccessible::updateAccessibility(&
event);
6588#if QT_CONFIG(graphicsview)
6589 if (
const auto &topData =
window()->d_func()->extra) {
6590 if (topData->proxyWidget) {
6591 if (previousProxyFocus && previousProxyFocus !=
f) {
6594 QPointer<QWidget> that = previousProxyFocus;
6600#if QT_CONFIG(graphicsview)
6602 if (
const auto &topData =
window()->d_func()->extra)
6603 if (topData->proxyWidget && topData->proxyWidget->hasFocus())
6604 topData->proxyWidget->d_func()->updateProxyInputMethodAcceptanceFromWidget();
6608 QPointer<QWidget> that =
f;
6617 f->d_func()->updateFocusChild();
6637 focusProxy = nextFocusProxy;
6644 const auto platformWindow =
w->handle();
6645 return platformWindow && platformWindow->isEmbedded();
6673 if (
q->isHidden()) {
6674 while (
w &&
w->isHidden()) {
6675 w->d_func()->focus_child =
q;
6680 w->d_func()->focus_child =
q;
6681 w =
w->isWindow() ?
nullptr :
w->parentWidget();
6724 QObject *originalFocusObject =
nullptr;
6725 if (extra && extra->
window) {
6729 if (!originalFocusObject)
6736 if (
w->d_func()->focus_child ==
this)
6737 w->d_func()->focus_child =
nullptr;
6748#if QT_CONFIG(graphicsview)
6749 const auto &topData = d_func()->extra;
6750 if (topData && topData->proxyWidget)
6751 topData->proxyWidget->clearFocus();
6757#if QT_CONFIG(accessibility)
6758 QAccessibleEvent
event(
this, QAccessible::Focus);
6759 QAccessible::updateAccessibility(&
event);
6812 return p->focusNextPrevChild(
next);
6813#if QT_CONFIG(graphicsview)
6815 if (
d->extra &&
d->extra->proxyWidget)
6816 return d->extra->proxyWidget->focusNextPrevChild(
next);
6819 bool wrappingOccurred =
false;
6822 if (!
w)
return false;
6831 if (wrappingOccurred) {
6836 if (winp->platformWindow !=
nullptr) {
6839 winp->platformWindow->windowEvent(&
event);
6840 if (
event.isAccepted())
return true;
6845 w->setFocus(reason);
6860 return const_cast<QWidget *
>(d_func()->focus_child);
6916#if QT_CONFIG(graphicsview)
6917 if (
const auto &tlwExtra = tlw->d_func()->extra) {
6918 if (
isVisible() && tlwExtra->proxyWidget)
6919 return tlwExtra->proxyWidget->isActiveWindow();
6930 !
w->isModal() &&
w->parentWidget()) {
6931 w =
w->parentWidget()->window();
6941 QWindowContainer *qwc = qww ? qobject_cast<QWindowContainer *>(qww->widget()) : 0;
6942 if (qwc && qwc->topLevelWidget() == tlw)
6955 return w->handle()->isActive();
7019 qWarning(
"QWidget::setTabOrder: 'first' and 'second' must be in the same window");
7038 for (
auto *
object :
target->children()) {
7040 if (
w &&
w->focusProxy() ==
target) {
7050 if (focusNext == noFurtherThan)
7053 lastFocusChild = focusNext;
7056 return lastFocusChild;
7059 QWidget *lastFocusChildOfFirst = determineLastFocusChild(
first, second);
7060 if (lastFocusChildOfFirst == second)
7061 lastFocusChildOfFirst =
first;
7062 QWidget *lastFocusChildOfSecond = determineLastFocusChild(second,
first);
7063 if (lastFocusChildOfSecond ==
first)
7064 lastFocusChildOfSecond = second;
7068 QWidget *prevWithFocus = oldPrev;
7069 while (prevWithFocus->focusPolicy() ==
Qt::NoFocus)
7071 if (prevWithFocus ==
first)
7106 if (oldtlw ==
q->window())
7126 QRect fs =
d->frameStrut();
7130 return data->crect.size();
7146 d->topData()->posIncludesFrame =
false;
7150 d->setDirtyOpaqueRegion();
7154 d->topData()->posIncludesFrame =
true;
7155 data->crect.moveTopLeft(
p);
7159 if (
d->extra &&
d->extra->hasWindowContainer)
7176 if (te->posIncludesFrame) {
7180 te->posIncludesFrame = 0;
7182 if (
q->windowHandle() &&
q->windowHandle()->handle()) {
7184 if (!
q->data->fstrut_dirty) {
7185 data.crect.translate(te->frameStrut.x(), te->frameStrut.y());
7186 te->posIncludesFrame = 0;
7205 d->fixPosIncludesFrame();
7207 d->setDirtyOpaqueRegion();
7209 const auto oldRect =
data->crect;
7211 if (oldRect !=
data->crect)
7222 d->topData()->posIncludesFrame = 0;
7224 d->setGeometry_sys(
r.x(),
r.y(),
r.width(),
r.height(),
true);
7225 d->setDirtyOpaqueRegion();
7227 const auto oldRect =
data->crect;
7228 data->crect.setTopLeft(
r.topLeft());
7230 if (oldRect !=
data->crect) {
7236 if (
d->extra &&
d->extra->hasWindowContainer)
7250 if (
q->isWindow() &&
q->windowHandle()) {
7255 w =
q->windowHandle()->width();
7256 h =
q->windowHandle()->height();
7260 QPoint oldp =
q->geometry().topLeft();
7264 bool isResize = olds !=
r.size();
7266 isMove = oldp !=
r.topLeft();
7271 if (
r.size() == olds && oldp ==
r.topLeft())
7274 if (!
data.in_set_window_state) {
7275 q->data->window_state &=
~Qt::WindowMaximized;
7276 q->data->window_state &=
~Qt::WindowFullScreen;
7284 bool needsShow =
false;
7286 if (
q->isWindow() ||
q->windowHandle()) {
7298 if (
q->isVisible()) {
7301 if (
q->isWindow()) {
7302 if (isResize && !isMove)
7304 else if (isMove && !isResize)
7305 win->setPosition(
x,
y);
7309 QPoint posInNativeParent =
q->mapTo(
q->nativeParentWidget(),
QPoint());
7317 if (!
q->isWindow()) {
7319 QRegion updateRegion(
q->geometry());
7320 updateRegion +=
QRect(oldPos, olds);
7321 q->parentWidget()->d_func()->invalidateBackingStore(updateRegion);
7322 }
else if (isMove && !isResize) {
7337 if (
q->windowHandle())
7341 if (isMove &&
q->pos() != oldPos)
7370 stream.setVersion(QDataStream::Qt_4_0);
7371 const quint32 magicNumber = 0x1D9D0CB;
7419 const int height = restoredGeometry->height() + frameHeight;
7424 restoredGeometry->setHeight(availableGeometry.
height() - 2 - frameHeight);
7425 if (availableGeometry.
width() <= restoredGeometry->width())
7426 restoredGeometry->setWidth(availableGeometry.
width() - 2);
7430 const QRect restored = restoredGeometry->
adjusted(0, -frameHeight, 0, 0);
7433 if (availableGeometry.
contains(restored))
7439 if (restored.top() <= availableGeometry.
top()) {
7440 restoredGeometry->moveTop(availableGeometry.
top() + 1 + frameHeight);
7441 }
else if (restored.bottom() >= availableGeometry.
bottom()) {
7443 restoredGeometry->moveBottom(availableGeometry.
bottom() - 1);
7447 if (restored.left() <= availableGeometry.
left()) {
7448 restoredGeometry->moveLeft(availableGeometry.
left() + 1);
7449 }
else if (restored.right() >= availableGeometry.
right()) {
7451 restoredGeometry->moveRight(availableGeometry.
right() - 1);
7483 stream.setVersion(QDataStream::Qt_4_0);
7485 const quint32 magicNumber = 0x1D9D0CB;
7487 stream >> storedMagicNumber;
7488 if (storedMagicNumber != magicNumber)
7495 stream >> majorVersion >> minorVersion;
7501 QRect restoredFrameGeometry;
7502 QRect restoredGeometry;
7503 QRect restoredNormalGeometry;
7504 qint32 restoredScreenNumber;
7507 qint32 restoredScreenWidth = 0;
7509 stream >> restoredFrameGeometry
7510 >> restoredNormalGeometry
7511 >> restoredScreenNumber
7515 if (majorVersion > 1)
7516 stream >> restoredScreenWidth;
7517 if (majorVersion > 2)
7518 stream >> restoredGeometry;
7523 restoredScreenNumber = 0;
7525 const qreal screenWidthF = restoredScreen ?
qreal(restoredScreen->geometry().width()) : 0;
7528 if (restoredScreenWidth) {
7529 const qreal factor =
qreal(restoredScreenWidth) / screenWidthF;
7530 if (factor < 0.8 || factor > 1.25)
7543 if (!restoredNormalGeometry.isValid())
7545 if (!restoredNormalGeometry.isValid()) {
7547 restoredNormalGeometry.setSize(restoredNormalGeometry
7549 .expandedTo(d_func()->adjustedSize()));
7552 const QRect availableGeometry = restoredScreen ? restoredScreen->availableGeometry()
7577 if (restoredScreen !=
screen()) {
7590 d_func()->topData()->normalGeometry = restoredNormalGeometry;
7595 if (majorVersion > 2)
7622 if (
left ==
d->leftmargin &&
top ==
d->topmargin
7625 d->leftmargin =
left;
7630 d->updateContentsRect();
7662 q->updateGeometry();
7664 if (
q->isVisible()) {
7686 QMargins userMargins(
d->leftmargin,
d->topmargin,
d->rightmargin,
d->bottommargin);
7688 userMargins |
d->safeAreaMargins() : userMargins;
7705 if (!nativeWidget->windowHandle())
7708 QPlatformWindow *platformWindow = nativeWidget->windowHandle()->handle();
7709 if (!platformWindow)
7714 if (!
q->isWindow()) {
7729 const QWidget *assumedSafeWidget =
nullptr;
7748 assumedSafeWidget =
w;
7752#if !defined(QT_DEBUG)
7753 if (assumedSafeWidget) {
7765 QRect widgetRect =
q->isVisible() ?
q->visibleRegion().boundingRect() :
q->rect();
7766 QPoint bottomRightMargins = widgetRect.bottomRight() -
q->mapFrom(nativeWidget,
7771 qMax(0, bottomRightMargins.x()),
qMax(0, bottomRightMargins.y()));
7855 if (
d->extra &&
d->extra->focus_proxy)
7856 d->extra->focus_proxy->setFocusPolicy(
policy);
7891 d->setUpdatesEnabled_helper(
enable);
7912 Qt::WindowState defaultState = platformIntegration->defaultWindowState(
data->window_flags);
7934 q->ensurePolished();
7936 if (!
q->isWindow() &&
q->parentWidget()->d_func()->layout && !
q->parentWidget()->data->in_show)
7937 q->parentWidget()->d_func()->layout->activate();
7949 disableUpdates = disableUpdates &&
q->updatesEnabled();
7973 child->d_func()->sendPendingMoveAndResizeEvents(recursive, disableUpdates);
7986 child->ensurePolished();
7990 if (childPrivate->layout)
7991 childPrivate->
layout->activate();
7994 const bool wasVisible =
child->isVisible();
7999 childPrivate->activateChildLayoutsRecursively();
8010 data.in_show =
true;
8023#if QT_CONFIG(graphicsview)
8047#if QT_CONFIG(graphicsview)
8051 if (ancestorProxy) {
8053 ancestorProxy->d_func()->embedSubWindow(
q);
8068 qApp->d_func()->openPopup(
q);
8070#if QT_CONFIG(accessibility)
8072 QAccessibleEvent
event(
q, QAccessible::ObjectShow);
8073 QAccessible::updateAccessibility(&
event);
8088 data.in_show =
false;
8124 QRect geomRect =
q->geometry();
8125 if (!
q->isWindow()) {
8126 QPoint topLeftOfWindow =
q->mapTo(
q->nativeParentWidget(),
QPoint());
8127 geomRect.moveTopLeft(topLeftOfWindow);
8130 if (windowRect != geomRect) {
8133 window->setGeometry(geomRect);
8135 window->resize(geomRect.size());
8142 window->setNativeWindowVisibility(
true);
8144 if (
window->isTopLevel()) {
8145 const QPoint crectTopLeft =
q->data->crect.topLeft();
8146 const QPoint windowTopLeft =
window->geometry().topLeft();
8147 if (crectTopLeft ==
QPoint(0, 0) && windowTopLeft != crectTopLeft)
8148 q->data->crect.moveTopLeft(windowTopLeft);
8176#if QT_CONFIG(graphicsview)
8183 qApp->d_func()->closePopup(
q);
8202 qApp->d_func()->sendSyntheticEnterLeave(
q);
8206 q->focusNextPrevChild(
true);
8214 repaintManager->removeDirtyWidget(
q);
8216#if QT_CONFIG(accessibility)
8218 QAccessibleEvent
event(
q, QAccessible::ObjectHide);
8219 QAccessible::updateAccessibility(&
event);
8245 if (!
q->isWindow()) {
8247 if (
p &&
p->isVisible()) {
8249 p->d_func()->invalidateBackingStore(
q->geometry());
8258 window->setNativeWindowVisibility(
false);
8287 qCDebug(lcWidgetShowHide) <<
"Setting visibility of" <<
this
8288 <<
"with attributes" << WidgetAttributes{
this}
8289 <<
"to" <<
visible <<
"via QWidget";
8306 qCDebug(lcWidgetShowHide) <<
"Setting visibility of" <<
q
8307 <<
"with attributes" << WidgetAttributes{
q}
8308 <<
"to" << visible <<
"via QWidgetPrivate";
8312 if (!
q->isWindow() &&
q->parentWidget() &&
q->parentWidget()->isVisible()
8314 q->parentWidget()->window()->d_func()->createRecursively();
8324 Qt::WindowStates initialWindowState =
q->windowState();
8327 q->ensurePolished();
8334 if (needUpdateGeometry)
8341 if (!
q->isWindow()) {
8344 parent->d_func()->layout->activate();
8350 parent->d_func()->setDirtyOpaqueRegion();
8355 && (
q->isWindow() || !
q->parentWidget()->d_func()->layout)) {
8356 if (
q->isWindow()) {
8358 if (
q->windowState() != initialWindowState)
8359 q->setWindowState(initialWindowState);
8368 if (
q->isWindow() ||
q->parentWidget()->isVisible()) {
8371 qApp->d_func()->sendSyntheticEnterLeave(
q);
8384 if (!
q->isWindow() &&
q->parentWidget())
8385 q->parentWidget()->d_func()->setDirtyOpaqueRegion();
8393 if (!
q->isWindow() &&
q->parentWidget()) {
8394 if (
q->parentWidget()->d_func()->layout)
8395 q->parentWidget()->d_func()->layout->invalidate();
8396 else if (
q->parentWidget()->isVisible())
8423 q->setVisible(
true);
8429 qCDebug(lcWidgetShowHide) <<
"Showing children of" <<
q
8430 <<
"spontaneously" << spontaneous;
8432 QList<QObject*> childList =
children;
8433 for (
int i = 0;
i < childList.size(); ++
i) {
8438 <<
"with attributes" << WidgetAttributes{
widget};
8445 widget->d_func()->showChildren(
true);
8447 QApplication::sendSpontaneousEvent(
widget, &e);
8450 widget->d_func()->show_recursive();
8460 qCDebug(lcWidgetShowHide) <<
"Hiding children of" <<
q
8461 <<
"spontaneously" << spontaneous;
8463 QList<QObject*> childList =
children;
8464 for (
int i = 0;
i < childList.size(); ++
i) {
8469 <<
"with attributes" << WidgetAttributes{
widget};
8477 widget->d_func()->hideChildren(spontaneous);
8480 QApplication::sendSpontaneousEvent(
widget, &e);
8487 widget->d_func()->hide_sys();
8490 qApp->d_func()->sendSyntheticEnterLeave(
widget);
8491#if QT_CONFIG(accessibility)
8493 QAccessibleEvent
event(
widget, QAccessible::ObjectHide);
8494 QAccessible::updateAccessibility(&
event);
8503 widgetWindow && widgetWindow->data->is_closing) {
8529 qCDebug(lcWidgetShowHide) <<
"Handling close event for" <<
q;
8531 if (
data.is_closing)
8535 data.is_closing =
true;
8537 QPointer<QWidget> that =
q;
8539 if (
data.in_destructor)
8545 QApplication::sendSpontaneousEvent(
q, &e);
8549 data.is_closing =
false;
8555 if (!that.isNull() && !
q->isHidden())
8558 if (!that.isNull()) {
8559 data.is_closing =
false;
8593 return d_func()->close();
8607 if (widgetWindow->isTopLevel())
8608 return widgetWindow->close();
8677 while (!
w->isHidden()
8679 &&
w->parentWidget()
8680 &&
w->parentWidget() != ancestor)
8700 QRect clipRect =
d->clipRect();
8704 d->subtractOpaqueChildren(
r, clipRect);
8705 d->subtractOpaqueSiblings(
r);
8716 if (
q->isWindow()) {
8717 Qt::Orientations exp;
8724 if (
q->sizePolicy().hasHeightForWidth())
8725 s.setHeight(
q->heightForWidth(
s.width()));
8726 exp =
q->sizePolicy().expandingDirections();
8729 s.setWidth(
qMax(
s.width(), 200));
8731 s.setHeight(
qMax(
s.height(), 100));
8743 extra->sizeAdjusted =
true;
8779 d->layout->activate();
8805 return d->layout->totalSizeHint();
8806 return QSize(-1, -1);
8832 return d->layout->totalMinimumSize();
8833 return QSize(-1, -1);
8856 if (
child->isWindow())
8901 switch(
event->type()) {
8916#if QT_CONFIG(wheelevent)
8924 switch (
event->type()) {
8957#if QT_CONFIG(wheelevent)
8959 wheelEvent((QWheelEvent*)
event);
8962#if QT_CONFIG(tabletevent)
8969 tabletEvent((QTabletEvent*)
event);
8985#ifdef QT_KEYPAD_NAVIGATION
8986 if (!k->
isAccepted() && QApplication::keypadNavigationEnabled()
9009#if QT_CONFIG(whatsthis)
9012 &&
d->whatsThis.size()) {
9033 for (
uint i = 0;
i < 32; ++
i) {
9063 d->resolvePalette();
9069 d->setWindowIcon_sys();
9070 d->setWindowIcon_helper();
9075 d->updateWidgetTransform(
event);
9083#if QT_CONFIG(statustip)
9084 if (
d->statusTip.size()) {
9093#if QT_CONFIG(statustip)
9094 if (
d->statusTip.size()) {
9117 d->updateWidgetTransform(
event);
9122 d->updateWidgetTransform(
event);
9129#ifndef QT_NO_CONTEXTMENU
9131 switch (
data->context_menu_policy) {
9142 if (
d->actions.size()) {
9156#if QT_CONFIG(draganddrop)
9158 dropEvent((QDropEvent*)
event);
9162 dragEnterEvent((QDragEnterEvent*)
event);
9166 dragMoveEvent((QDragMoveEvent*)
event);
9170 dragLeaveEvent((QDragLeaveEvent*)
event);
9192 d->resolvePalette();
9221 if (!
d->childrenShownByExpose) {
9223 d->showChildren(
true);
9227 d->childrenHiddenByWState =
false;
9231 d->hideChildren(
true);
9232 d->childrenHiddenByWState =
true;
9234 d->childrenShownByExpose =
false;
9244 QList<QObject*> childList =
d->children;
9245 for (
int i = 0;
i < childList.size(); ++
i) {
9247 if (
w &&
w->isVisible() && !
w->isWindow())
9255 QList<QObject*> childList =
d->children;
9256 for (
int i = 0;
i < childList.size(); ++
i) {
9266 d->resolveLayoutDirection();
9271 d->layout->invalidate();
9276 d->syncBackingStore();
9290 if (!
d->children.isEmpty()) {
9292 for (
int i = 0;
i <
d->children.size(); ++
i) {
9294 if (
o &&
o != modalWidget &&
o->isWidgetType()) {
9303#if QT_CONFIG(tooltip)
9305 if (!
d->toolTip.isEmpty())
9311#if QT_CONFIG(whatsthis)
9313 if (
d->whatsThis.size())
9319 if (
d->whatsThis.isEmpty())
9324 d->topData()->frameStrut.setCoords(0 ,0, 0, 0);
9325 data->fstrut_dirty =
false;
9340 QList<QObject*> childList =
d->children;
9341 for (
int i = 0;
i < childList.size(); ++
i) {
9343 if (
w &&
w->isVisible() && !
w->isWindow())
9356#ifndef QT_NO_GESTURES
9362 if (
const QTLWExtra *te =
d->maybeTopData()) {
9369 d->updateFont(
d->data.fnt);
9370 d->renderToTextureReallyDirty = 1;
9374 if (propName.
size() == 13 && !
qstrncmp(propName,
"_q_customDpi", 12)) {
9378 const char axis = propName.
at(12);
9380 d->extra->customDpiX =
value;
9381 else if (axis ==
'Y')
9382 d->extra->customDpiY =
value;
9383 d->updateFont(
d->data.fnt);
9413 switch(
event->type()) {
9416#if QT_CONFIG(accessibility)
9419 QAccessibleStateChangeEvent
event(
this,
s);
9420 QAccessible::updateAccessibility(&
event);
9431 d->layout->invalidate();
9564#if QT_CONFIG(wheelevent)
9579void QWidget::wheelEvent(QWheelEvent *
event)
9585#if QT_CONFIG(tabletevent)
9606void QWidget::tabletEvent(QTabletEvent *
event)
9637#ifndef QT_NO_SHORTCUT
9725#if !defined(QT_PLATFORM_UIKIT)
9890#ifndef QT_NO_CONTEXTMENU
9955 return d_func()->clipRect();
9990 while (
priv->inheritsInputMethodHints) {
9991 priv =
priv->q_func()->parentWidget()->d_func();
9994 return priv->imHints;
10004 if (
d->imHints == hints)
10006 d->imHints = hints;
10015#if QT_CONFIG(draganddrop)
10031void QWidget::dragEnterEvent(QDragEnterEvent *)
10049void QWidget::dragMoveEvent(QDragMoveEvent *)
10065void QWidget::dragLeaveEvent(QDragLeaveEvent *)
10080void QWidget::dropEvent(QDropEvent *)
10194 if (
m ==
d->polished)
10202 QList<QObject*>
children =
d->children;
10205 if (!
o->isWidgetType())
10207 if (
QWidget *
w = qobject_cast<QWidget *>(
o))
10208 w->ensurePolished();
10211 if (
d->parent &&
d->sendChildEvents) {
10226 return d->extra ?
d->extra->mask :
QRegion();
10240 return d_func()->
layout;
10272 qWarning(
"QWidget::setLayout: Cannot set layout to 0");
10277 qWarning(
"QWidget::setLayout: Attempting to set QLayout \"%s\" on %s \"%s\", which already has a"
10284 if (oldParent && oldParent !=
this) {
10285 if (oldParent->isWidgetType()) {
10289 oldParentWidget->takeLayout();
10291 qWarning(
"QWidget::setLayout: Attempting to set QLayout \"%s\" on %s \"%s\", when the QLayout already has a parent",
10299 l->d_func()->topLevel =
true;
10301 if (oldParent !=
this) {
10303 l->d_func()->reparentChildWidgets(
this);
10308 d->topData()->sizeAdjusted =
false;
10318QLayout *QWidget::takeLayout()
10324 d->layout =
nullptr;
10357 return d->size_policy;
10364 if (
policy ==
d->size_policy)
10368 d->retainSizeWhenHiddenChanged = 1;
10372#if QT_CONFIG(graphicsview)
10373 if (
const auto &extra =
d->extra) {
10374 if (extra->proxyWidget)
10375 extra->proxyWidget->setSizePolicy(
policy);
10380 d->retainSizeWhenHiddenChanged = 0;
10383 d->topData()->sizeAdjusted =
false;
10421 return d->layout ?
d->layout->hasHeightForWidth() :
d->size_policy.hasHeightForWidth();
10441 return d_func()->childAt_helper(
p,
false);
10459 || (ignoreChildrenInDestructor &&
child->data->in_destructor)) {
10465 childPoint -=
child->data->crect.topLeft();
10468 if (!
child->d_func()->pointInsideRectAndMask(childPoint))
10472 if (
QWidget *
w =
child->d_func()->childAtRecursiveHelper(childPoint, ignoreChildrenInDestructor))
10490 if (!
q->isWindow() && !isHidden && (
parent =
q->parentWidget())) {
10491 if (
parent->d_func()->layout)
10492 parent->d_func()->layout->invalidate();
10493 else if (
parent->isVisible())
10512 d->updateGeometry_helper(
false);
10536 d->setWindowFlags(
flags);
10551 d->setWindowFlags(
data->window_flags | flag);
10553 d->setWindowFlags(
data->window_flags & ~flag);
10563 if (
q->data->window_flags ==
flags)
10569 bool visible =
q->isVisible();
10570 const bool windowFlagChanged = (
q->data->window_flags ^
flags) &
Qt::Window;
10571 q->setParent(
q->parentWidget(),
flags);
10575 if (!windowFlagChanged && (visible ||
q->testAttribute(
Qt::WA_Moved)))
10580 q->data->window_flags =
flags;
10645 if (
d->renderToTexture) {
10650 for (
int i = 0;
i <
d->children.size(); ++
i) {
10652 if (
w && !
w->isWindow())
10674 const auto checkForParentChildLoops =
qScopeGuard([&](){
10678 if (++
depth == QObjectPrivate::CheckForParentChildLoopsWarnDepth) {
10679 qWarning(
"QWidget %p (class: '%s', object name: '%s') may have a loop in its parent-child chain; "
10680 "this is undefined behavior",
10683 p =
p->parentWidget();
10692 QWidget *oldParentWithWindow =
d->closestParentWidgetWithWindowHandle();
10695 d->data.fstrut_dirty =
true;
10697 QWidget *desktopWidget =
nullptr;
10702 if (newParent &&
parent && !desktopWidget) {
10704 parent->d_func()->enforceNativeChildren();
10735 const bool oldParentUsesRhiFlush = oldParentWithWindow ? oldParentWithWindow->d_func()->usesRhiFlush :
false;
10749 if (
d->textureChildSeen &&
parent) {
10756 oldPaintManager->removeDirtyWidget(
this);
10759 oldPaintManager->moveStaticWidgets(
this);
10762 d->reparentFocusWidgets(oldtlw);
10765 const bool useStyleSheetPropagationInWidgetStyles =
10772 const auto pd =
parent->d_func();
10773 d->inheritedFontResolveMask = pd->directFontResolveMask | pd->inheritedFontResolveMask;
10774 d->inheritedPaletteResolveMask = pd->directPaletteResolveMask | pd->inheritedPaletteResolveMask;
10777 d->resolvePalette();
10779 d->resolveLayoutDirection();
10780 d->resolveLocale();
10786 if (newParent || !wasCreated
10796 d->setUpdatesEnabled_helper(
parent ?
parent->updatesEnabled() :
true);
10801 if (
parent &&
d->sendChildEvents) {
10806 if (
parent &&
d->sendChildEvents &&
d->polished) {
10817 if (oldParentUsesRhiFlush && oldtlw !=
window())
10827 d->updateIsOpaque();
10829#if QT_CONFIG(graphicsview)
10832 if (oldtlw->graphicsProxyWidget()) {
10834 ancestorProxy->d_func()->unembedSubWindow(
this);
10838 ancestorProxy->d_func()->embedSubWindow(
this);
10842 if (
d->extra &&
d->extra->hasWindowContainer)
10845 QWidget *newParentWithWindow =
d->closestParentWidgetWithWindowHandle();
10846 if (newParentWithWindow && newParentWithWindow != oldParentWithWindow) {
10848 qCDebug(lcWidgetPainting) <<
"Evaluating whether reparenting of" <<
this
10849 <<
"into" <<
parent <<
"requires RHI enablement for" << newParentWithWindow;
10865 auto *existingWindow = newParentWithWindow->windowHandle();
10866 auto existingSurfaceType = existingWindow->surfaceType();
10867 if (existingSurfaceType != surfaceType) {
10869 <<
"Recreating" << existingWindow
10870 <<
"with current type" << existingSurfaceType
10871 <<
"to support" << surfaceType;
10872 const auto windowStateBeforeDestroy = newParentWithWindow->windowState();
10873 const auto visibilityBeforeDestroy = newParentWithWindow->isVisible();
10874 newParentWithWindow->destroy();
10875 newParentWithWindow->create();
10876 Q_ASSERT(newParentWithWindow->windowHandle());
10877 newParentWithWindow->windowHandle()->setWindowStates(windowStateBeforeDestroy);
10879 }
else if (
auto *
backingStore = newParentWithWindow->backingStore()) {
10895 Qt::WindowFlags oldFlags =
data.window_flags;
10898 QScreen *targetScreen =
nullptr;
10900 if (newparent && newparent->windowType() ==
Qt::Desktop) {
10903 targetScreen = newparent->screen();
10904 newparent =
nullptr;
10912 targetScreen =
q->parentWidget()->window()->screen();
10915 const bool destroyWindow = (
10922 if (
parent != newparent) {
10926 if (
q->windowHandle())
10927 q->windowHandle()->setFlags(
f);
10942 if (destroyWindow) {
10948 if (!
q->windowHandle()->children().isEmpty()) {
10950 QWindow *newParentWindow = parentWithWindow ? parentWithWindow->windowHandle() :
nullptr;
10952 if (
QWindow *childWindow = qobject_cast<QWindow *>(
child)) {
10953 qCWarning(lcWidgetWindow) <<
"Reparenting" << childWindow
10954 <<
"before destroying" <<
this;
10955 childWindow->setParent(newParentWindow);
10963 q->destroy(
true,
false);
10967 data.window_flags =
f;
10975 if (
q->isWindow() || (!newparent || newparent->isVisible()) || explicitlyHidden)
10980 if (!newparent && targetScreen) {
10983 q->windowHandle()->setScreen(targetScreen);
10993 if (parentWithWindow) {
11007 qCDebug(lcWidgetWindow) <<
"Setting" <<
window <<
"transient parent to" << transientParent;
11008 window->setTransientParent(transientParent);
11009 window->setParent(
nullptr);
11011 auto *parentWindow = parentWithWindow->windowHandle();
11012 qCDebug(lcWidgetWindow) <<
"Reparenting" <<
window <<
"into" << parentWindow;
11013 window->setTransientParent(
nullptr);
11014 window->setParent(parentWindow);
11017 qCDebug(lcWidgetWindow) <<
"Making" <<
window <<
"top level window";
11018 window->setTransientParent(
nullptr);
11019 window->setParent(
nullptr);
11029 if (
auto *childWidget = qobject_cast<QWidget*>(
child)) {
11031 childPrivate->reparentWidgetWindows(parentWithWindow);
11061 if (dx == 0 && dy == 0)
11064#if QT_CONFIG(graphicsview)
11071 proxy->scroll(dx, dy,
proxy->subWidgetRect(
this));
11075 d->setDirtyOpaqueRegion();
11076 d->scroll_sys(dx, dy);
11101 if (dx == 0 && dy == 0)
11104#if QT_CONFIG(graphicsview)
11109 if (!
d->dirty.isEmpty()) {
11110 for (
const QRect &
rect :
d->dirty.translated(dx, dy) &
r)
11113 proxy->scroll(dx, dy,
r.translated(
proxy->subWidgetRect(
this).topLeft().toPoint()));
11117 d->scroll_sys(dx, dy,
r);
11156 if (
x >
data->crect.width() ||
y >
data->crect.height())
11160 w =
data->crect.width() -
x;
11162 h =
data->crect.height() -
y;
11188template <
typename T>
11193 if (!
q->isVisible() || !
q->updatesEnabled() ||
r.isEmpty())
11197 if (tlwExtra && tlwExtra->backingStore && tlwExtra->repaintManager)
11253template <
typename T>
11263 if (!
q->isVisible() || !
q->updatesEnabled())
11266 T clipped =
r &
q->rect();
11268 if (clipped.isEmpty())
11277 if (tlwExtra && tlwExtra->backingStore && tlwExtra->repaintManager)
11278 tlwExtra->repaintManager->markDirty(clipped,
q);
11296 const int int_off =
x / (8*
sizeof(
uint));
11298 d->high_attributes[int_off] |= (1<<(
x-(int_off*8*
sizeof(
uint))));
11300 d->high_attributes[int_off] &= ~(1<<(
x-(int_off*8*
sizeof(
uint))));
11305void QWidgetPrivate::macUpdateSizeAttribute()
11316 w->d_func()->macUpdateSizeAttribute();
11335 "QWidget::setAttribute(WidgetAttribute, bool): "
11336 "QWidgetPrivate::high_attributes[] too small to contain all attributes in WidgetAttribute");
11342 if (
d->noPaintOnScreen)
11358#if QT_CONFIG(draganddrop)
11369 for (
int i = 0;
i <
d->children.size(); ++
i) {
11379 d->sendChildEvents = !on;
11382 d->receiveChildEvents = !on;
11392 for (
int i = 0;
i < 3; ++
i) {
11396 d->macUpdateSizeAttribute();
11426 d->createTLExtra();
11428 d->createTLSysExtra();
11448 d->updateIsOpaque();
11451 d->updateIsOpaque();
11454 d->updateIsOpaque();
11457 d->updateSystemBackground();
11472 d->resolvePalette();
11474 d->resolveLocale();
11500 d->setNetWmWindowTypes();
11506 repaintManager->addStaticWidget(
this);
11508 repaintManager->removeStaticWidget(
this);
11514 d->updateIsTranslucent();
11535 const int int_off =
x / (8*
sizeof(
uint));
11536 return (
d->high_attributes[int_off] & (1<<(
x-(int_off*8*
sizeof(
uint)))));
11567 return (
isWindow() &&
d->maybeTopData()) ?
d->maybeTopData()->opacity / 255. : 1.0;
11580 d->setWindowOpacity_sys(opacity);
11585#if QT_CONFIG(graphicsview)
11600 if (
q->windowHandle())
11601 q->windowHandle()->setOpacity(
level);
11638 d->setWindowModified_helper();
11651 if (!platformWindow)
11655 if (
Q_UNLIKELY(on && !
q->windowTitle().contains(
"[*]"_L1)))
11656 qWarning(
"QWidget::setWindowModified: The window title does not contain a '[*]' placeholder");
11662#if QT_CONFIG(tooltip)
11681void QWidget::setToolTip(
const QString &
s)
11690QString QWidget::toolTip()
const
11707void QWidget::setToolTipDuration(
int msec)
11710 d->toolTipDuration = msec;
11713int QWidget::toolTipDuration()
const
11716 return d->toolTipDuration;
11722#if QT_CONFIG(statustip)
11731void QWidget::setStatusTip(
const QString &
s)
11737QString QWidget::statusTip()
const
11740 return d->statusTip;
11744#if QT_CONFIG(whatsthis)
11754void QWidget::setWhatsThis(
const QString &
s)
11760QString QWidget::whatsThis()
const
11763 return d->whatsThis;
11767#if QT_CONFIG(accessibility)
11789void QWidget::setAccessibleName(
const QString &
name)
11792 d->accessibleName =
name;
11793 QAccessibleEvent
event(
this, QAccessible::NameChanged);
11794 QAccessible::updateAccessibility(&
event);
11797QString QWidget::accessibleName()
const
11800 return d->accessibleName;
11819void QWidget::setAccessibleDescription(
const QString &description)
11822 d->accessibleDescription = description;
11823 QAccessibleEvent
event(
this, QAccessible::DescriptionChanged);
11824 QAccessible::updateAccessibility(&
event);
11827QString QWidget::accessibleDescription()
const
11830 return d->accessibleDescription;
11834#ifndef QT_NO_SHORTCUT
11951 const int parentChildCount =
p->d_func()->children.size();
11952 if (parentChildCount < 2)
11954 const int from =
p->d_func()->children.indexOf(
this);
11957 if (from != parentChildCount -1)
11958 p->d_func()->children.move(from, parentChildCount - 1);
11961 else if (from == parentChildCount - 1)
11965 d->subtractOpaqueSiblings(region);
11966 d->invalidateBackingStore(region);
11971 if (
d->extra &&
d->extra->hasWindowContainer)
11982 q->windowHandle()->raise();
12005 const int parentChildCount =
p->d_func()->children.size();
12006 if (parentChildCount < 2)
12008 const int from =
p->d_func()->children.indexOf(
this);
12012 p->d_func()->children.move(from, 0);
12015 else if (from == 0)
12021 if (
d->extra &&
d->extra->hasWindowContainer)
12033 q->windowHandle()->lower();
12051 if (!
w ||
isWindow() ||
p !=
w->parentWidget() ||
this ==
w)
12054 int from =
p->d_func()->children.indexOf(
this);
12055 int to =
p->d_func()->children.indexOf(
w);
12062 p->d_func()->children.move(from, to);
12065 else if (from == to)
12069 d->stackUnder_sys(
w);
12129 return QRect(0, 0, 1, 1);
12132 if (
data.fstrut_dirty
12144 if (
q->data->fstrut_dirty) {
12146 if (te->window && te->window->handle()) {
12147 const QMargins margins = te->window->frameMargins();
12148 if (!margins.
isNull()) {
12149 te->frameStrut.setCoords(margins.
left(), margins.
top(), margins.
right(), margins.
bottom());
12150 q->data->fstrut_dirty =
false;
12157#ifdef QT_KEYPAD_NAVIGATION
12166bool QWidgetPrivate::navigateToDirection(Direction
direction)
12171 return (targetWidget != 0);
12189 const int sourceX =
12191 (sourceRect.
left() + (sourceRect.
right() - sourceRect.
left()) / 2)
12193 const int sourceY =
12195 (sourceRect.
top() + (sourceRect.
bottom() - sourceRect.
top()) / 2)
12197 const QPoint sourcePoint(sourceX, sourceY);
12201 QWidget *targetWidget =
nullptr;
12202 int shortestDistance = INT_MAX;
12205 for (
QWidget *targetCandidate : targetCandidates) {
12207 const QRect targetCandidateRect = targetCandidate->rect().
translated(targetCandidate->mapToGlobal(
QPoint()));
12212 if (targetCandidate->focusProxy() || targetCandidateRect.isEmpty())
12216 if ( targetCandidate != sourceWidget
12228 && targetCandidate->isEnabled()
12230 && targetCandidate->isVisible()
12232 && targetCandidate->window() == sourceWindow) {
12233 const int targetCandidateDistance = [](
const QPoint &sourcePoint,
12234 const QRect &targetCandidateRect) {
12237 if (
p.x() <
r.left())
12238 dx =
r.left() -
p.x();
12239 else if (
p.x() >
r.right())
12240 dx =
p.x() -
r.right();
12241 if (
p.y() <
r.top())
12242 dy =
r.top() -
p.y();
12243 else if (
p.y() >
r.bottom())
12244 dy =
p.y() -
r.bottom();
12247 if (targetCandidateDistance < shortestDistance) {
12248 shortestDistance = targetCandidateDistance;
12249 targetWidget = targetCandidate;
12253 return targetWidget;
12290 if (qobject_cast<const QTabWidget*>(tabWidget))
12321 if (!repaintManager)
12374 q->updateGeometry();
12383 myOpt.rect.setRect(0, 0, 32768, 32768);
12387 QRect liRect =
q->style()->subElementRect(element,
opt,
q);
12388 if (liRect.isValid()) {
12405 if (!
q->parentWidget()) {
12437 return widget->d_func();
12441#if QT_CONFIG(graphicsview)
12455 return d->extra->proxyWidget;
12461#ifndef QT_NO_GESTURES
12471 d->gestureContext.insert(gesture,
flags);
12485 if (
d->gestureContext.remove(gesture)) {
12487 manager->cleanupCachedGestures(
this, gesture);
12509 d->aboutToDestroy();
12512 d->deactivateWidgetCleanup();
12515 qApp->d_func()->closePopup(
this);
12517 if (
this ==
qApp->activeWindow())
12527 if (destroySubWindows) {
12529 for (
int i = 0;
i < childList.size();
i++) {
12538 if (destroyWindow) {
12539 d->deleteTLSysExtra();
12562 qWarning(
"QWidget::paintEngine: Should no longer be called");
12591#if QT_CONFIG(graphicsview)
12597 result =
d->extra->proxyWidget;
12610 result.window =
nullptr;
12611 for ( ;
w ;
w =
w->parentWidget()) {
12612#if QT_CONFIG(graphicsview)
12615 const QList <QGraphicsView *> views =
scene->
views();
12616 if (!views.isEmpty()) {
12617 result.transform *= qgpw->sceneTransform();
12618 result.transform *= views.first()->viewportTransform();
12619 w = views.first()->viewport();
12630 const QPoint topLeft =
w->geometry().topLeft();
12631 result.transform.translate(topLeft.
x(), topLeft.
y());
12652 return t.window ?
t.window->mapToGlobal(
g) :
g;
12675 const QPointF windowLocal =
t.window ?
t.window->mapFromGlobal(
pos) :
pos;
12676 return t.transform.inverted().map(windowLocal);
12697 window = nativeParent->windowHandle();
12701#ifndef QT_NO_CURSOR
12712#ifndef QT_NO_CURSOR
12718 window->setMouseGrabEnabled(
true);
12729#ifndef QT_NO_CURSOR
12735 window->setMouseGrabEnabled(
false);
12790#ifndef QT_NO_CURSOR
12803 return window ?
window->setMouseGrabEnabled(grab) :
false;
12842 window->setKeyboardGrabEnabled(
true);
12852 return window ?
window->setKeyboardGrabEnabled(grab) :
false;
12866 window->setKeyboardGrabEnabled(
false);
12932 wnd->requestActivate();
12952 auto resolveDevicePixelRatio = [
this,
screen]() ->
qreal {
12964 return data->crect.width();
12968 return data->crect.height();
12975 if (
p->d_func()->extra &&
p->d_func()->extra->customDpiX)
12976 return p->d_func()->extra->customDpiX;
12981 if (
p->d_func()->extra &&
p->d_func()->extra->customDpiY)
12982 return p->d_func()->extra->customDpiY;
12990 return resolveDevicePixelRatio();
13014 painter->d_func()->state->deviceFont =
f;
13036 if (!d_func()->redirectDev)
13040 if (!
sp || !
sp->isActive())
13043 if (
sp->paintEngine()->paintDevice() != d_func()->redirectDev)
13076 if (newMask ==
d->extra->mask)
13079#ifndef QT_NO_BACKINGSTORE
13080 const QRegion oldMask(
d->extra->mask);
13083 d->extra->mask = newMask;
13084 d->extra->hasMask = !newMask.isEmpty();
13089 d->setMask_sys(newMask);
13091#ifndef QT_NO_BACKINGSTORE
13095 if (!
d->extra->hasMask) {
13099 if (!expose.isEmpty()) {
13100 d->setDirtyOpaqueRegion();
13109 parentExpose -= newMask;
13110 if (!parentExpose.isEmpty()) {
13111 d->setDirtyOpaqueRegion();
13112 parentExpose.translate(
data->crect.topLeft());
13117 if (!oldMask.isEmpty())
13118 update(newMask - oldMask);
13127 window->setMask(region);
13170 if (!
d->extra || !
d->extra->hasMask)
13177 Q_ASSERT(widgetAsObject->isWidgetType());
13189 if (
q->isVisible()) {
13190 std::stringstream
s;
13192 <<
q->width() <<
'x' <<
q->height()
13193 << std::showpos <<
q->x() <<
q->y()
13207 if (!
q->windowHandle())
13210 QXcbWindow::WindowTypes wmWindowType = QXcbWindow::None;
13212 wmWindowType |= QXcbWindow::Desktop;
13214 wmWindowType |= QXcbWindow::Dock;
13216 wmWindowType |= QXcbWindow::Toolbar;
13218 wmWindowType |= QXcbWindow::Menu;
13220 wmWindowType |= QXcbWindow::Utility;
13222 wmWindowType |= QXcbWindow::Splash;
13224 wmWindowType |= QXcbWindow::Dialog;
13226 wmWindowType |= QXcbWindow::DropDownMenu;
13228 wmWindowType |= QXcbWindow::PopupMenu;
13230 wmWindowType |= QXcbWindow::Tooltip;
13232 wmWindowType |= QXcbWindow::Notification;
13234 wmWindowType |= QXcbWindow::Combo;
13236 wmWindowType |= QXcbWindow::Dnd;
13238 if (wmWindowType == QXcbWindow::None && skipIfMissing)
13241 if (
auto *xcbWindow =
dynamic_cast<QXcbWindow*
>(
q->windowHandle()->handle()))
13242 xcbWindow->setWindowType(wmWindowType);
13259 && (!excludeChildrenOf || !excludeChildrenOf->isAncestorOf(
child))) {
13266#ifndef QT_NO_DEBUG_STREAM
13276 const QMetaEnum me = qtMo->enumerator(qtMo->indexOfEnumerator(
"WidgetAttribute"));
13299 if (
debug.verbosity() > 2) {
13303 debug <<
", visible";
13305 debug <<
", disabled";
13308 debug <<
", attributes=" << WidgetAttributes{
widget};
13310 debug <<
", window";
13318 debug <<
", margins=" << margins;
13326 debug <<
"QWidget(0x0)";
13335#define FOCUS_NEXT(w) w->d_func()->focus_next
13336#define FOCUS_PREV(w) w->d_func()->focus_prev
13366 qFatal() <<
q <<
"has inconsistent focus chain.";
13368 qCDebug(lcWidgetFocus) <<
q <<
"wasn't removed, because of inconsistent focus chain.";
13373 qCDebug(lcWidgetFocus) <<
q <<
"wasn't removed, because it is not part of a focus chain.";
13383 qCDebug(lcWidgetFocus) <<
q <<
"removed from focus chain.";
13394 qCDebug(lcWidgetFocus) <<
"Initializing focus chain of" <<
q;
13414 bool prevWasNew =
true;
13421 bool currentIsNew =
q->isAncestorOf(
widget);
13422 if (currentIsNew) {
13443 prevWasNew = currentIsNew;
13452 if (!
q->isWindow()) {
13483 qCDebug(lcWidgetFocus) <<
"No-op insertion." <<
q <<
"is already before" <<
position;
13498 qCDebug(lcWidgetFocus) <<
"No-op insertion." <<
q <<
"is already after" <<
position;
13527 if (toBeInserted.isEmpty()) {
13528 qCDebug(lcWidgetFocus) <<
"No-op insertion of an empty list";
13534 "Coding error: toBeInserted contains position");
13537 QWidget *last = toBeInserted.constLast();
13540 if (toBeInserted.count() == 1)
13547 qCDebug(lcWidgetFocus) <<
"No-op insertion." << toBeInserted <<
"is already before"
13555 qCDebug(lcWidgetFocus) << toBeInserted <<
"inserted before" <<
position;
13559 qCDebug(lcWidgetFocus) <<
"No-op insertion." << toBeInserted <<
"is already after"
13567 qCDebug(lcWidgetFocus) << toBeInserted <<
"inserted after" <<
position;
13596 if (
path.contains(current))
13599 }
while (current != to);
13616 if (
path.isEmpty()) {
13617 qCDebug(lcWidgetFocus) <<
"No-op removal. Focus chain from" << from <<
"doesn't lead to " << to;
13623 if (
first == last) {
13624 first->d_func()->removeFromFocusChain();
13632 qCDebug(lcWidgetFocus) <<
path <<
"removed from focus chain";
13657 for (
auto *
object : std::as_const(
q->children())) {
13659 if (
w &&
w->focusProxy() ==
q) {
13660 lastFocusChild =
w;
13664 }
else if (
q->isAncestorOf(focusProxy)) {
13665 lastFocusChild = focusProxy;
13668 && focusNext->window() == focusProxy->
window();
13670 if (focusNext == noFurtherThan)
13673 lastFocusChild = focusNext;
13676 return lastFocusChild;
13751 qCDebug(lcWidgetFocus) <<
"Focus chain leading from" <<
q <<
"to" <<
position <<
"is not closed.";
13761#include "moc_qwidget.cpp"
13762#include "moc_qwidget_p.cpp"
static bool isEqual(const aiUVTransform &a, const aiUVTransform &b)
IOBluetoothDevice * device
static void(* destroyed)(QAbstractDeclarativeData *, QObject *)
The QActionEvent class provides an event that is generated when a QAction is added,...
QObjectList associatedObjects
The QAction class provides an abstraction for user commands that can be added to different user inter...
QList< QObject * > associatedObjects() const
static QWidget * focus_widget
static QWidget * hidden_focus_widget
static void setFocusWidget(QWidget *focus, Qt::FocusReason reason)
static QWidget * focusNextPrevChild_helper(QWidget *toplevel, bool next, bool *wrappingOccurred=nullptr)
internal Helper function that returns the new focus widget, but does not set the focus reason.
static bool isBlockedByModal(QWidget *widget)
static void setActiveWindow(QWidget *act)
static QStyle * style()
Returns the application's style object.
static QPalette palette()
Returns the current application palette.
static QWidget * activeModalWidget()
Returns the active modal widget.
static QWidget * focusWidget()
Returns the application widget that has the keyboard input focus, or \nullptr if no widget in this ap...
static QFont font()
Returns the default application font.
static QWidget * activePopupWidget()
Returns the active popup widget.
static QWidget * activeWindow()
Returns the application top-level window that has the keyboard input focus, or \nullptr if no applica...
static QWidgetList allWidgets()
Returns a list of all the widgets in the application.
static QSurface::SurfaceType surfaceTypeForConfig(const QPlatformBackingStoreRhiConfig &config)
static bool checkForceRhi(QPlatformBackingStoreRhiConfig *outConfig, QSurface::SurfaceType *outType)
The QBackingStore class provides a drawing area for QWindow.
QPlatformBackingStore * handle() const
Returns a pointer to the QPlatformBackingStore implementation.
bool isOpaque() const
Returns true if the brush is fully opaque otherwise false.
QPixmap texture() const
Returns the custom brush pattern, or a null pixmap if no custom brush pattern has been set.
Qt::BrushStyle style() const
Returns the brush style.
char * data()
\macro QT_NO_CAST_FROM_BYTEARRAY
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
char at(qsizetype i) const
Returns the byte at index position i in the byte array.
The QCloseEvent class contains parameters that describe a close event.
The QColor class provides colors based on RGB, HSV or CMYK values.
void setAlphaF(float alpha)
Sets the alpha of this color to alpha.
static bool is_app_closing
static bool testAttribute(uint flag)
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
static void removePostedEvents(QObject *receiver, int eventType=0)
static void processEvents(QEventLoop::ProcessEventsFlags flags=QEventLoop::AllEvents)
Processes some pending events for the calling thread according to the specified flags.
static QCoreApplication * instance() noexcept
Returns a pointer to the application's QCoreApplication (or QGuiApplication/QApplication) instance.
static bool closingDown()
Returns true if the application objects are being destroyed; otherwise returns false.
static bool testAttribute(Qt::ApplicationAttribute attribute)
Returns true if attribute attribute is set; otherwise returns false.
static void postEvent(QObject *receiver, QEvent *event, int priority=Qt::NormalEventPriority)
The QCursor class provides a mouse cursor with an arbitrary shape.
Qt::CursorShape shape() const
Returns the cursor shape identifier.
\inmodule QtCore\reentrant
Type
This enum type defines the valid event types in Qt.
@ ApplicationPaletteChange
@ WindowAboutToChangeInternal
@ ApplicationLayoutDirectionChange
@ ApplicationWindowIconChange
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
The QFocusEvent class contains event parameters for widget focus events.
QFont resolve(const QFont &) const
Returns a new QFont that has attributes copied from other that have not been previously set on this f...
void setResolveMask(uint mask)
static QGestureManager * instance(InstanceCreation ic=ForceCreation)
The QGraphicsEffectSource class represents the source on which a QGraphicsEffect is installed on.
The QGraphicsEffect class is the base class for all graphics effects.
PixmapPadMode
This enum describes how the pixmap returned from sourcePixmap should be padded.
@ PadToEffectiveBoundingRect
QGraphicsEffectSource * source() const
virtual void draw(QPainter *painter)=0
This pure virtual function draws the effect and is called whenever the source needs to be drawn.
The QGraphicsScene class provides a surface for managing a large number of 2D graphical items.
QList< QGraphicsView * > views() const
Returns a list of all the views that display this scene.
void update(qreal x, qreal y, qreal w, qreal h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static void showModalWindow(QWindow *window)
static void hideModalWindow(QWindow *window)
static QPlatformIntegration * platformIntegration()
static QGuiApplicationPrivate * instance()
static Qt::ApplicationState applicationState()
QScreen * primaryScreen
the primary (or default) screen of the application.
static QPalette palette()
Returns the current application palette.
static QObject * focusObject()
Returns the QObject in currently active window that will be final receiver of events tied to focus,...
static QWindow * focusWindow()
Returns the QWindow that receives events tied to focus, such as key events.
static QInputMethod * inputMethod()
returns the input method.
static void setOverrideCursor(const QCursor &)
Sets the application override cursor to cursor.
static void restoreOverrideCursor()
Undoes the last setOverrideCursor().
static bool desktopSettingsAware()
Returns true if Qt is set to use the system's standard colors, fonts, etc.; otherwise returns false.
Qt::LayoutDirection layoutDirection
the default layout direction for this application
static QScreen * screenAt(const QPoint &point)
Returns the screen at point, or \nullptr if outside of any screen.
static QList< QScreen * > screens()
Returns a list of all the screens associated with the windowing system the application is connected t...
QIcon windowIcon
the default window icon
The QHelpEvent class provides an event that is used to request helpful information about a particular...
const QPoint & globalPos() const
Returns the mouse cursor position when the event was generated in global coordinates.
The QHideEvent class provides an event which is sent after a widget is hidden.
The QIcon class provides scalable icons in different modes and states.
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
@ Format_ARGB32_Premultiplied
The QKeyEvent class describes a key event.
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately after the event occurred.
int key() const
Returns the code of the key that was pressed or released.
The QKeySequence class encapsulates a key sequence as used by shortcuts.
virtual QRect geometry() const =0
Returns the rectangle covered by this layout item.
virtual bool hasHeightForWidth() const
Returns true if this layout's preferred height depends on its width; otherwise returns false.
virtual QLayout * layout()
If this item is a QLayout, it is returned as a QLayout; otherwise \nullptr is returned.
The QLayout class is the base class of geometry managers.
QRect geometry() const override
\reimp
int totalHeightForWidth(int w) const
void update()
Updates the layout for parentWidget().
bool activate()
Redoes the layout for parentWidget() if necessary.
Qt::Orientations expandingDirections() const override
Returns whether this layout can make use of more space than sizeHint().
void invalidate() override
\reimp
QWidget * parentWidget() const
Returns the parent widget of this layout, or \nullptr if this layout is not installed on any widget.
QLayout * layout() override
\reimp
virtual int indexOf(const QWidget *) const
Searches for widget widget in this layout (not including child layouts).
qsizetype size() const noexcept
bool isEmpty() const noexcept
const_reference at(qsizetype i) const noexcept
qsizetype removeAll(const AT &t)
void append(parameter_type t)
bool isDebugEnabled() const
Returns true if debug messages should be shown for this category; false otherwise.
constexpr int bottom() const noexcept
Returns the bottom margin.
constexpr bool isNull() const noexcept
Returns true if all margins are is 0; otherwise returns false.
constexpr int left() const noexcept
Returns the left margin.
constexpr int right() const noexcept
Returns the right margin.
constexpr int top() const noexcept
Returns the top margin.
The QMoveEvent class contains event parameters for move events.
void setParent_helper(QObject *)
virtual std::string flagsForDumping() const
const QObjectList & children() const
Returns a list of child objects.
QObject * parent() const
Returns a pointer to the parent object.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
QString objectName
the name of this object
virtual bool event(QEvent *event)
This virtual function receives events to an object and should return true if the event e was recogniz...
void setParent(QObject *parent)
Makes the object a child of parent.
QList< QByteArray > dynamicPropertyNames() const
bool setProperty(const char *name, const QVariant &value)
Sets the value of the object's name property to value.
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
bool isWidgetType() const
Returns true if the object is a widget; otherwise returns false.
bool paintingActive() const
qreal devicePixelRatio() const
@ PdmDevicePixelRatioF_EncodedB
@ PdmDevicePixelRatioF_EncodedA
@ PdmDevicePixelRatioScaled
virtual QPaintDevice * redirected(QPoint *offset) const
static int encodeMetricF(PaintDeviceMetric metric, double value)
virtual int metric(PaintDeviceMetric metric) const
virtual QPaintEngine * paintEngine() const =0
static qreal devicePixelRatioFScale()
void setSystemViewport(const QRegion ®ion)
QTransform systemTransform
virtual void systemStateChanged()
void setSystemTransformAndViewport(const QTransform &xform, const QRegion ®ion)
The QPaintEvent class contains event parameters for paint events.
The QPainter class performs low-level painting on widgets and other paint devices.
CompositionMode compositionMode() const
Returns the current composition mode.
const QPen & pen() const
Returns the painter's current pen.
Qt::LayoutDirection layoutDirection() const
Returns the layout direction used by the painter when drawing text.
RenderHints renderHints() const
Returns a flag that specifies the rendering hints that are set for this painter.
QPaintDevice * device() const
Returns the paint device on which this painter is currently painting, or \nullptr if the painter is n...
QPaintEngine * paintEngine() const
Returns the paint engine that the painter is currently operating on if the painter is active; otherwi...
void setBrushOrigin(int x, int y)
This is an overloaded member function, provided for convenience. It differs from the above function o...
const QFont & font() const
Returns the currently set font used for drawing text.
void setLayoutDirection(Qt::LayoutDirection direction)
Sets the layout direction used by the painter when drawing text, to the specified direction.
void drawTiledPixmap(const QRectF &rect, const QPixmap &pm, const QPointF &offset=QPointF())
Draws a tiled pixmap, inside the given rectangle with its origin at the given position.
void restore()
Restores the current painter state (pops a saved state off the stack).
const QTransform & worldTransform() const
Returns the world transformation matrix.
void setCompositionMode(CompositionMode mode)
Sets the composition mode to the given mode.
void save()
Saves the current painter state (pushes the state onto a stack).
QRegion clipRegion() const
Returns the currently set clip region.
const QTransform & deviceTransform() const
Returns the matrix that transforms from logical coordinates to device coordinates of the platform dep...
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device.
CompositionMode
Defines the modes supported for digital image compositing.
bool isActive() const
Returns true if begin() has been called and end() has not yet been called; otherwise returns false.
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
void setRenderHints(RenderHints hints, bool on=true)
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
bool hasClipping() const
Returns true if clipping has been set; otherwise returns false.
void setClipRegion(const QRegion &, Qt::ClipOperation op=Qt::ReplaceClip)
Sets the clip region to the given region using the specified clip operation.
void setTransform(const QTransform &transform, bool combine=false)
The QPalette class contains color groups for each widget state.
const QBrush & brush(ColorGroup cg, ColorRole cr) const
Returns the brush in the specified color group, used for the given color role.
void setCurrentColorGroup(ColorGroup cg)
Set the palette's current color group to cg.
void setResolveMask(ResolveMask mask)
ResolveMask resolveMask() const
QPalette resolve(const QPalette &other) const
Returns a new QPalette that is a union of this instance and other.
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
\inmodule QtCore\reentrant
constexpr QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
\inmodule QtCore\reentrant
constexpr int x() const noexcept
Returns the x coordinate of this point.
constexpr int y() const noexcept
Returns the y coordinate of this point.
\inmodule QtCore\reentrant
QRect toAlignedRect() const noexcept
constexpr QRectF translated(qreal dx, qreal dy) const noexcept
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis,...
constexpr QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const noexcept
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
\inmodule QtCore\reentrant
constexpr bool isEmpty() const noexcept
Returns true if the rectangle is empty, otherwise returns false.
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr bool isNull() const noexcept
Returns true if the rectangle is a null rectangle, otherwise returns false.
constexpr int bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
constexpr QPoint topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
constexpr QRect adjusted(int x1, int y1, int x2, int y2) const noexcept
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
constexpr int top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
bool contains(const QRect &r, bool proper=false) const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
constexpr int left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr void setWidth(int w) noexcept
Sets the width of the rectangle to the given width.
constexpr QSize size() const noexcept
Returns the size of the rectangle.
constexpr void translate(int dx, int dy) noexcept
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position.
constexpr int width() const noexcept
Returns the width of the rectangle.
constexpr QRect translated(int dx, int dy) const noexcept
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis,...
constexpr int y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr QPoint center() const noexcept
Returns the center point of the rectangle.
constexpr int right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
The QRegion class specifies a clip region for a painter.
QRect boundingRect() const noexcept
Returns the bounding rectangle of this region.
void translate(int dx, int dy)
Translates (moves) the region dx along the X axis and dy along the Y axis.
bool intersects(const QRegion &r) const
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
QRegion translated(int dx, int dy) const
The QResizeEvent class contains event parameters for resize events.
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
The QScreen class is used to query screen properties. \inmodule QtGui.
qreal logicalDotsPerInchY
the number of logical dots or pixels per inch in the vertical direction
qreal devicePixelRatio
the screen's ratio between physical pixels and device-independent pixels
qreal logicalDotsPerInchX
the number of logical dots or pixels per inch in the horizontal direction
QSizeF physicalSize
the screen's physical size (in millimeters)
QRect geometry
the screen's geometry in pixels
qreal physicalDotsPerInchY
the number of physical dots or pixels per inch in the vertical direction
int depth
the color depth of the screen
qreal physicalDotsPerInchX
the number of physical dots or pixels per inch in the horizontal direction
The QShowEvent class provides an event that is sent when a widget is shown.
constexpr qreal width() const noexcept
Returns the width.
constexpr qreal height() const noexcept
Returns the height.
The QSizePolicy class is a layout attribute describing horizontal and vertical resizing policy.
constexpr bool retainSizeWhenHidden() const noexcept
constexpr void setHeight(int h) noexcept
Sets the height to the given height.
The QStatusTipEvent class provides an event that is used to show messages in a status bar.
\macro QT_RESTRICTED_CAST_FROM_ASCII
qsizetype indexOf(QLatin1StringView s, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
bool isNull() const
Returns true if this string is null; otherwise returns false.
QByteArray toLocal8Bit() const &
The QStyleOption class stores the parameters used by QStyle functions.
void initFrom(const QWidget *w)
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
virtual void polish(QWidget *widget)
Initializes the appearance of the given widget.
@ SH_Widget_ShareActivation
@ SH_TitleBar_ModifyNotification
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr, QStyleHintReturn *returnData=nullptr) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
SubElement
This enum represents a sub-area of a widget.
SurfaceType
The SurfaceType enum describes what type of surface this is.
static void showText(const QPoint &pos, const QString &text, QWidget *w=nullptr)
Shows text as a "What's This?" window, at global position pos.
static void parentWasChanged(QWidget *parent)
static void parentWasRaised(QWidget *parent)
static void parentWasMoved(QWidget *parent)
static void parentWasLowered(QWidget *parent)
static void toplevelAboutToBeDestroyed(QWidget *parent)
void focusObjectChanged(QObject *object)
This signal is emitted when the final receiver of events tied to focus is changed to object.
QSet< QString >::iterator it
Combined button and popup list for selecting options.
@ ImInputItemClipRectangle
@ NavigationModeKeypadDirectional
@ NavigationModeKeypadTabOrder
QTextStream & hex(QTextStream &stream)
Calls QTextStream::setIntegerBase(16) on stream and returns stream.
@ WA_X11NetWmWindowTypeDND
@ WA_X11NetWmWindowTypePopupMenu
@ WA_WState_ExplicitShowHide
@ WA_WState_WindowOpacitySet
@ WA_TransparentForMouseEvents
@ WA_ForceUpdatesDisabled
@ WA_MacAlwaysShowToolWindow
@ WA_X11NetWmWindowTypeDock
@ WA_X11NetWmWindowTypeUtility
@ WA_X11NetWmWindowTypeDialog
@ WA_X11NetWmWindowTypeSplash
@ WA_X11NetWmWindowTypeDropDownMenu
@ WA_TranslucentBackground
@ WA_NoChildEventsFromChildren
@ WA_ContentsMarginsRespectsSafeArea
@ WA_X11NetWmWindowTypeToolTip
@ WA_X11NetWmWindowTypeCombo
@ WA_X11NetWmWindowTypeToolBar
@ WA_NoChildEventsForParent
@ WA_DontCreateNativeAncestors
@ WA_ShowWithoutActivating
@ WA_X11NetWmWindowTypeMenu
@ WA_WState_OwnSizePolicy
@ WA_X11NetWmWindowTypeDesktop
@ WA_X11NetWmWindowTypeNotification
QTextStream & noforcesign(QTextStream &stream)
Calls QTextStream::setNumberFlags(QTextStream::numberFlags() & ~QTextStream::ForceSign) on stream and...
QTextStream & dec(QTextStream &stream)
Calls QTextStream::setIntegerBase(10) on stream and returns stream.
@ FindChildrenRecursively
@ AA_DontCreateNativeWidgetSiblings
@ AA_UseStyleSheetPropagationInWidgetStyles
QTextStream & forcesign(QTextStream &stream)
Calls QTextStream::setNumberFlags(QTextStream::numberFlags() | QTextStream::ForceSign) on stream and ...
@ WindowContextHelpButtonHint
@ WindowFullscreenButtonHint
@ WindowMaximizeButtonHint
@ WindowMinimizeButtonHint
@ WindowMinMaxButtonsHint
@ WindowTransparentForInput
@ MaximizeUsingFullscreenGeometryHint
Q_WIDGETS_EXPORT QWidget * qt_button_down
void qt_qpa_set_cursor(QWidget *w, bool force)
int qstrncmp(const char *str1, const char *str2, size_t len)
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
EGLOutputLayerEXT EGLint attribute
bool qFuzzyIsNull(qfloat16 f) noexcept
int qRound(qfloat16 d) noexcept
#define Q_LOGGING_CATEGORY(name,...)
#define qCInfo(category,...)
#define qCWarning(category,...)
#define qCDebug(category,...)
#define Q_STATIC_LOGGING_CATEGORY(name,...)
QT_BEGIN_NAMESPACE constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qBound(const T &min, const T &val, const T &max)
constexpr const T & qMax(const T &a, const T &b)
static bool contains(const QJsonArray &haystack, unsigned needle)
GLsizei const GLfloat * v
[13]
GLuint64 GLenum void * handle
GLint GLint GLint GLint GLint x
[0]
GLint GLenum GLsizei GLsizei GLsizei depth
GLenum GLuint GLint level
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLdouble GLdouble GLdouble GLdouble top
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLuint GLsizei const GLchar * message
GLenum GLuint GLintptr offset
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLint GLsizei GLsizei GLenum format
GLfloat GLfloat GLfloat GLfloat h
GLsizei GLsizei GLchar * source
GLuint GLenum GLenum transform
GLsizei GLfixed GLfixed GLfixed GLfixed const GLubyte * bitmap
GLdouble GLdouble GLdouble GLdouble q
GLsizei const GLchar *const * path
static const QRectF boundingRect(const QPointF *points, int pointCount)
static constexpr quint16 currentMajorVersion
\qmltype FileInstancing \inherits Instancing \inqmlmodule QtQuick3D
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
static QT_BEGIN_NAMESPACE qreal dpr(const QWindow *w)
void forceUpdate(QQuickItem *item)
#define Q_ASSERT_X(cond, x, msg)
QScopeGuard< typename std::decay< F >::type > qScopeGuard(F &&f)
[qScopeGuard]
#define qPrintable(string)
static char * toLocal8Bit(char *out, QStringView in, QStringConverter::State *state)
QStyleSheetStyle * qt_styleSheet(QStyle *style)
#define QT_CONFIG(feature)
Q_CORE_EXPORT bool qEnvironmentVariableIsSet(const char *varName) noexcept
Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=nullptr) noexcept
Q_GUI_EXPORT QWindowPrivate * qt_window_private(QWindow *window)
QT_BEGIN_NAMESPACE typedef QHash< WId, QWidget * > QWidgetMapper
QList< QWidget * > QWidgetList
static QWindowsDirect2DWindow * nativeWindow(QWindow *window)
static QRect frameGeometry(HWND hwnd, bool topLevel)
const char className[16]
[1]
if(qFloatDistance(a, b)<(1<< 7))
[0]
obj metaObject() -> className()
QList< QWidget * > widgets
[11]
QGraphicsOpacityEffect * effect
the effect attached to this item
QNetworkAccessManager manager
qsizetype indexOf(const AT &t, qsizetype from=0) const noexcept