diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-05-06 12:02:19 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-05-06 12:02:19 +0200 |
commit | 2105800b94edcae55c6e226d8dc3ec6e1c204ab2 (patch) | |
tree | db4e73cab40502618389c8957ceab3d6011c69ae /src/mainwindow/widgets | |
parent | QTBUG-18665 workaround (diff) | |
download | smolbote-2105800b94edcae55c6e226d8dc3ec6e1c204ab2.tar.xz |
Tabifying dock widgets
Diffstat (limited to 'src/mainwindow/widgets')
-rw-r--r-- | src/mainwindow/widgets/dockwidget.cpp | 25 | ||||
-rw-r--r-- | src/mainwindow/widgets/dockwidget.h | 23 |
2 files changed, 48 insertions, 0 deletions
diff --git a/src/mainwindow/widgets/dockwidget.cpp b/src/mainwindow/widgets/dockwidget.cpp new file mode 100644 index 0000000..f70e26f --- /dev/null +++ b/src/mainwindow/widgets/dockwidget.cpp @@ -0,0 +1,25 @@ +/* + * This file is part of smolbote. It's copyrighted by the contributors recorded + * in the version control history of the file, available from its original + * location: https://neueland.iserlohn-fortress.net/smolbote.hg + * + * SPDX-License-Identifier: GPL-3.0 + */ + +#include "dockwidget.h" +#include <QCloseEvent> + +DockWidget::DockWidget(const QString &title, QWidget *parent, Qt::WindowFlags flags) + : QDockWidget(title, parent, flags) +{ + setAttribute(Qt::WA_DeleteOnClose, true); +} + +DockWidget::~DockWidget() +{ + // dock widget takes ownership of its widget, so closing the dock widget + // causes it to delete the widget as well + // clear the widget's parent to prevent this + if(widget()) + widget()->setParent(nullptr); +} diff --git a/src/mainwindow/widgets/dockwidget.h b/src/mainwindow/widgets/dockwidget.h new file mode 100644 index 0000000..35a4cc7 --- /dev/null +++ b/src/mainwindow/widgets/dockwidget.h @@ -0,0 +1,23 @@ +/* + * This file is part of smolbote. It's copyrighted by the contributors recorded + * in the version control history of the file, available from its original + * location: https://neueland.iserlohn-fortress.net/smolbote.hg + * + * SPDX-License-Identifier: GPL-3.0 + */ + +#ifndef SMOLBOTE_DOCKWIDGET_H +#define SMOLBOTE_DOCKWIDGET_H + +#include <QDockWidget> + + +class DockWidget : public QDockWidget +{ +public: + DockWidget(const QString &title, QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags()); + ~DockWidget(); + +}; + +#endif // SMOLBOTE_DOCKWIDGET_H |