2022-05-10 10:06:48 +00:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
2025-09-18 16:07:53 +00:00
|
|
|
// Qt-Security score:significant reason:default
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
#ifndef QLAYOUT_P_H
|
|
|
|
#define QLAYOUT_P_H
|
|
|
|
|
|
|
|
//
|
|
|
|
// W A R N I N G
|
|
|
|
// -------------
|
|
|
|
//
|
|
|
|
// This file is not part of the Qt API. It exists for the convenience
|
|
|
|
// of qlayout*.cpp, and qabstractlayout.cpp. This header
|
|
|
|
// file may change from version to version without notice, or even be removed.
|
|
|
|
//
|
|
|
|
// We mean it.
|
|
|
|
//
|
|
|
|
|
2016-06-03 12:31:40 +00:00
|
|
|
#include <QtWidgets/private/qtwidgetsglobal_p.h>
|
2011-04-27 10:05:43 +00:00
|
|
|
#include "private/qobject_p.h"
|
|
|
|
#include "qstyle.h"
|
|
|
|
#include "qsizepolicy.h"
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
|
|
|
class QWidgetItem;
|
|
|
|
class QSpacerItem;
|
2012-09-03 04:35:39 +00:00
|
|
|
class QLayoutItem;
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2011-06-08 07:51:07 +00:00
|
|
|
class Q_WIDGETS_EXPORT QLayoutPrivate : public QObjectPrivate
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
|
|
|
Q_DECLARE_PUBLIC(QLayout)
|
|
|
|
|
|
|
|
public:
|
|
|
|
typedef QWidgetItem * (*QWidgetItemFactoryMethod)(const QLayout *layout, QWidget *widget);
|
|
|
|
typedef QSpacerItem * (*QSpacerItemFactoryMethod)(const QLayout *layout, int w, int h, QSizePolicy::Policy hPolicy, QSizePolicy::Policy);
|
|
|
|
|
|
|
|
QLayoutPrivate();
|
|
|
|
|
|
|
|
void getMargin(int *result, int userMargin, QStyle::PixelMetric pm) const;
|
2019-10-08 06:05:26 +00:00
|
|
|
void doResize();
|
2011-04-27 10:05:43 +00:00
|
|
|
void reparentChildWidgets(QWidget *mw);
|
Avoid adding widget to its own layout
Widgets and layouts added or inserted to a layout are checked for:
- Not being NULL
- Not being the parent widget of a layout or the layout itself,
respectively
Without this commit, adding a widget to its own layout would result in a
CPU-hogging infinite loop. Now, a warning is written to stderr and the
add or insert function call is ignored.
The checks are implemented as public functions of QLayoutPrivate and
thus accessible in QLayout's descendants to be used in various
"addWidget", "insertWidget", etc functions.
Unlike 'classical' layouts like QGridLayout, QFormLayout does indeed
accept widgets that are NULL. To not break this behavior, any call for
the check functions first tests if the widget or layout, respectively,
to test is NULL or not and calls the check only in the latter case.
Automated tests for QBoxLayout, QGridLayout, and QFormLayout were added.
For an unpatched Qt 5.3, each of those automated tests will freeze as
explained in QTBUG-40609. For a fixed version, warning messages about
invalid parameters to addWidget/addLayout/... calls will be read by
QTest::ignoreMessage, resulting in a passed test.
Change-Id: I1522d5727e643da3f7c025755975aca9f482676d
Task-number: QTBUG-40609
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2014-08-24 12:01:26 +00:00
|
|
|
bool checkWidget(QWidget *widget) const;
|
|
|
|
bool checkLayout(QLayout *otherLayout) const;
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
static QWidgetItem *createWidgetItem(const QLayout *layout, QWidget *widget);
|
|
|
|
static QSpacerItem *createSpacerItem(const QLayout *layout, int w, int h, QSizePolicy::Policy hPolicy = QSizePolicy::Minimum, QSizePolicy::Policy vPolicy = QSizePolicy::Minimum);
|
2020-07-02 13:56:26 +00:00
|
|
|
virtual QLayoutItem* replaceAt(int, QLayoutItem *) { return nullptr; }
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
static QWidgetItemFactoryMethod widgetItemFactoryMethod;
|
|
|
|
static QSpacerItemFactoryMethod spacerItemFactoryMethod;
|
|
|
|
|
|
|
|
int insideSpacing;
|
|
|
|
int userLeftMargin;
|
|
|
|
int userTopMargin;
|
|
|
|
int userRightMargin;
|
|
|
|
int userBottomMargin;
|
|
|
|
uint topLevel : 1;
|
|
|
|
uint enabled : 1;
|
|
|
|
uint activated : 1;
|
|
|
|
uint autoNewChild : 1;
|
2024-08-19 12:41:55 +00:00
|
|
|
QLayout::SizeConstraint horizontalConstraint;
|
|
|
|
QLayout::SizeConstraint verticalConstraint;
|
2011-04-27 10:05:43 +00:00
|
|
|
QRect rect;
|
|
|
|
QWidget *menubar;
|
|
|
|
};
|
|
|
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
#endif // QLAYOUT_P_H
|