FACT++  1.0
DockWindow.cc
Go to the documentation of this file.
1 // **************************************************************************
7 // **************************************************************************
8 #include "DockWindow.h"
9 
10 #include <QDockWidget>
11 #include <QGridLayout>
12 
13 #include <stdexcept>
14 
15 using namespace std;
16 
17 DockWindow::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 
45 void 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 }
QTabWidget * fTabWidget
Definition: DockWindow.h:15
STL namespace.
QDockWidget * fDockWidget
Definition: DockWindow.h:12
void closeEvent(QCloseEvent *)
Definition: DockWindow.cc:45
DockWindow(QDockWidget *d, const QString &name)
Definition: DockWindow.cc:17