KDDockWidgets API Documentation  1.5
DockWidget.cpp
Go to the documentation of this file.
1 /*
2  This file is part of KDDockWidgets.
3 
4  SPDX-FileCopyrightText: 2019-2022 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 
24 using namespace KDDockWidgets;
25 
26 class DockWidget::Private
27 {
28 public:
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 
42 DockWidget::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) {
63  onHidden(e->spontaneous());
64  }
65 
66  return QWidget::event(e);
67 }
68 
70 {
71  onCloseEvent(e);
72 }
QVBoxLayout
QLayout::SetMinAndMaxSize
SetMinAndMaxSize
QEvent::ParentChange
ParentChange
KDDockWidgets::DockWidget::DockWidget
DockWidget(const QString &uniqueName, Options options=KDDockWidgets::DockWidgetBase::Options(), LayoutSaverOptions layoutSaverOptions=KDDockWidgets::DockWidgetBase::LayoutSaverOptions())
constructs a new DockWidget
Definition: DockWidget.cpp:42
QWidget::event
virtual bool event(QEvent *event) override
KDDockWidgets::DockWidget::closeEvent
void closeEvent(QCloseEvent *) override
Definition: DockWidget.cpp:69
QWidget
KDDockWidgets::DockWidgetBase::widgetChanged
void widgetChanged(KDDockWidgets::QWidgetOrQuick *)
emitted when the hosted widget changed
DockWidget.h
Represents a dock widget.
KDDockWidgets::DockWidget::~DockWidget
~DockWidget() override
destructor
Definition: DockWidget.cpp:51
KDDockWidgets::DockWidgetBase::onCloseEvent
void onCloseEvent(QCloseEvent *e) override
Definition: DockWidgetBase.cpp:788
QCloseEvent
KDDockWidgets::DockWidget
Represents a dock widget.
Definition: DockWidget.h:38
QString
KDDockWidgets::DockWidget::event
bool event(QEvent *) override
Definition: DockWidget.cpp:56
KDDockWidgets::DockWidgetBase::onHidden
void onHidden(bool spontaneous)
Definition: DockWidgetBase.cpp:763
QEvent::spontaneous
bool spontaneous() const const
QEvent::type
QEvent::Type type() const const
QEvent
KDDockWidgets::DockWidgetBase
The DockWidget base-class. DockWidget and DockWidgetBase are only split in two so we can share some c...
Definition: DockWidgetBase.h:61
KDDockWidgets
Definition: Config.cpp:36
KDDockWidgets::DockWidgetBase::onShown
void onShown(bool spontaneous)
Definition: DockWidgetBase.cpp:746
KDDockWidgets::DockWidgetBase::onParentChanged
void onParentChanged()
Definition: DockWidgetBase.cpp:733

© 2019-2022 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 Mon Mar 7 2022 02:01:20 for KDDockWidgets API Documentation by doxygen 1.8.20