source: trunk/FACT++/gui/DockWindow.cc@ 19333

Last change on this file since 19333 was 10657, checked in by tbretz, 14 years ago
Added or improved documentation.
File size: 1.5 KB
Line 
1// **************************************************************************
2/** @class DockWindow
3
4@brief A main window which can be used to display a QDockWidget from a tab
5
6*/
7// **************************************************************************
8#include "DockWindow.h"
9
10#include <QDockWidget>
11#include <QGridLayout>
12
13#include <stdexcept>
14
15using namespace std;
16
17DockWindow::DockWindow(QDockWidget *d, const QString &name)
18 : fDockWidget(d)
19{
20 QObject *w0 = d->parent(); // QWidget
21 if (!w0)
22 throw runtime_error("1st parent of QDockWidget is NULL");
23
24 QObject *w1 = w0->parent(); // QWidget
25 if (!w1)
26 throw runtime_error("2nd parent of QDockWidget is NULL");
27
28 QObject *w2 = w1->parent(); // QWidget
29 if (!w2)
30 throw runtime_error("3rd parent of QDockWidget is NULL");
31
32 fTabWidget = dynamic_cast<QTabWidget*>(w2);
33 if (!fTabWidget)
34 throw runtime_error("3rd parent of QDockWidget is not a QTabWidget");
35
36 setGeometry(d->geometry());
37 addDockWidget(Qt::LeftDockWidgetArea, fDockWidget);
38 setWindowTitle(name);
39
40 // FIXME: ToolTip, WhatsThis
41
42 show();
43}
44
45void DockWindow::closeEvent(QCloseEvent *)
46{
47 QWidget *w = new QWidget;
48
49 QGridLayout *l = new QGridLayout(w);
50 //layout->setObjectName(QString::fromUtf8("gridLayout_")+windowTitle());
51 l->addWidget(fDockWidget, 0, 0, 1, 1);
52
53 fTabWidget->addTab(w, windowTitle());
54 fTabWidget->setTabsClosable(true);
55
56 fDockWidget->setParent(w);
57}
Note: See TracBrowser for help on using the repository browser.