KDDockWidgets API Documentation 1.7
Loading...
Searching...
No Matches
DockWidget.cpp
Go to the documentation of this file.
1/*
2 This file is part of KDDockWidgets.
3
4 SPDX-FileCopyrightText: 2019-2023 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
5 Author: SĂ©rgio Martins <sergio.martins@kdab.com>
6
7 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
8
9 Contact KDAB at <info@kdab.com> for commercial licensing options.
10*/
11
12#include "DockWidget.h"
13
14#include <QCloseEvent>
15#include <QVBoxLayout>
16
24using namespace KDDockWidgets;
25
26class DockWidget::Private
27{
28public:
29 Private(DockWidget *q)
30 : layout(new QVBoxLayout(q))
31 {
32 layout->setSpacing(0);
33 layout->setContentsMargins(0, 0, 0, 0);
34
35 // propagate the max-size constraints from the guest widget to the DockWidget
36 layout->setSizeConstraint(QLayout::SetMinAndMaxSize);
37 }
38
39 QVBoxLayout *const layout;
40};
41
42DockWidget::DockWidget(const QString &name, Options options, LayoutSaverOptions layoutSaverOptions)
43 : DockWidgetBase(name, options, layoutSaverOptions)
44 , d(new Private(this))
45{
46 connect(this, &DockWidgetBase::widgetChanged, this, [this](QWidget *w) {
47 d->layout->addWidget(w);
48 });
49}
50
52{
53 delete d;
54}
55
57{
58 if (e->type() == QEvent::ParentChange) {
60 } else if (e->type() == QEvent::Show) {
61 onShown(e->spontaneous());
62 } else if (e->type() == QEvent::Hide) {
64 }
65
66 return QWidget::event(e);
67}
68
Represents a dock widget.
The DockWidget base-class. DockWidget and DockWidgetBase are only split in two so we can share some c...
void onHidden(bool spontaneous)
void widgetChanged(KDDockWidgets::QWidgetOrQuick *)
emitted when the hosted widget changed
void onCloseEvent(QCloseEvent *e) override
void onShown(bool spontaneous)
Represents a dock widget.
Definition DockWidget.h:38
void closeEvent(QCloseEvent *) override
bool event(QEvent *) override
DockWidget(const QString &uniqueName, Options options=KDDockWidgets::DockWidgetBase::Options(), LayoutSaverOptions layoutSaverOptions=KDDockWidgets::DockWidgetBase::LayoutSaverOptions())
constructs a new DockWidget
~DockWidget() override
destructor
bool spontaneous() const const
QEvent::Type type() const const
virtual bool event(QEvent *event) override

© 2019-2023 Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
KDDockWidgets
Advanced Dock Widget Framework for Qt
https://www.kdab.com/development-resources/qt-tools/kddockwidgets/
Generated on Wed Nov 1 2023 00:02:31 for KDDockWidgets API Documentation by doxygen 1.9.8