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

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