Qt 4.8
qdockwidget.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QDYNAMICDOCKWIDGET_H
43 #define QDYNAMICDOCKWIDGET_H
44 
45 #include <QtGui/qwidget.h>
46 
48 
50 
51 QT_MODULE(Gui)
52 
53 #ifndef QT_NO_DOCKWIDGET
54 
55 class QDockAreaLayout;
56 class QDockWidgetPrivate;
57 class QMainWindow;
59 
61 {
62  Q_OBJECT
63 
64  Q_FLAGS(DockWidgetFeatures)
65  bool floating;
66  DockWidgetFeatures features;
67  Qt::DockWidgetAreas allowedAreas;
68  QString windowTitle;
69 
70 public:
71  explicit QDockWidget(const QString &title, QWidget *parent = 0, Qt::WindowFlags flags = 0);
72  explicit QDockWidget(QWidget *parent = 0, Qt::WindowFlags flags = 0);
73  ~QDockWidget();
74 
75  QWidget *widget() const;
76  void setWidget(QWidget *widget);
77 
79  DockWidgetClosable = 0x01,
80  DockWidgetMovable = 0x02,
81  DockWidgetFloatable = 0x04,
82  DockWidgetVerticalTitleBar = 0x08,
83 
84  DockWidgetFeatureMask = 0x0f,
85  AllDockWidgetFeatures = DockWidgetClosable|DockWidgetMovable|DockWidgetFloatable, // ### remove in 5.0
86  NoDockWidgetFeatures = 0x00,
87 
88  Reserved = 0xff
89  };
90  Q_DECLARE_FLAGS(DockWidgetFeatures, DockWidgetFeature)
91 
92  void setFeatures(DockWidgetFeatures features);
93  DockWidgetFeatures features() const;
94 
95  void setFloating(bool floating);
96  inline bool isFloating() const { return isWindow(); }
97 
98  void setAllowedAreas(Qt::DockWidgetAreas areas);
99  Qt::DockWidgetAreas allowedAreas() const;
100 
101  void setTitleBarWidget(QWidget *widget);
102  QWidget *titleBarWidget() const;
103 
105  { return (allowedAreas() & area) == area; }
106 
107 #ifndef QT_NO_ACTION
108  QAction *toggleViewAction() const;
109 #endif
110 
111 Q_SIGNALS:
112  void featuresChanged(QDockWidget::DockWidgetFeatures features);
113  void topLevelChanged(bool topLevel);
114  void allowedAreasChanged(Qt::DockWidgetAreas allowedAreas);
115  void visibilityChanged(bool visible);
116  void dockLocationChanged(Qt::DockWidgetArea area);
117 
118 protected:
119  void changeEvent(QEvent *event);
120  void closeEvent(QCloseEvent *event);
121  void paintEvent(QPaintEvent *event);
122  bool event(QEvent *event);
123  void initStyleOption(QStyleOptionDockWidget *option) const;
124 
125 private:
128  Q_PRIVATE_SLOT(d_func(), void _q_toggleView(bool))
129  Q_PRIVATE_SLOT(d_func(), void _q_toggleTopLevel())
135 };
136 
137 Q_DECLARE_OPERATORS_FOR_FLAGS(QDockWidget::DockWidgetFeatures)
138 
139 #endif // QT_NO_DOCKWIDGET
140 
142 
144 
145 #endif // QDYNAMICDOCKWIDGET_H
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
The QStyleOptionDockWidget class is used to describe the parameters for drawing a dock widget...
Definition: qstyleoption.h:504
EventRef event
QPointer< QWidget > widget
#define QT_MODULE(x)
Definition: qglobal.h:2783
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition: qdockwidget.h:60
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
#define Q_DECLARE_FLAGS(Flags, Enum)
The Q_DECLARE_FLAGS() macro expands to.
Definition: qglobal.h:2348
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
bool isAreaAllowed(Qt::DockWidgetArea area) const
Returns true if this dock widget can be placed in the given area; otherwise returns false...
Definition: qdockwidget.h:104
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
#define Q_PRIVATE_SLOT(d, signature)
Definition: qobjectdefs.h:73
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_SIGNALS
Definition: qobjectdefs.h:72
virtual void paintEvent(QPaintEvent *)
This event handler can be reimplemented in a subclass to receive paint events passed in event...
Definition: qwidget.cpp:9548
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
The Q_DECLARE_OPERATORS_FOR_FLAGS() macro declares global operator|() functions for Flags...
Definition: qglobal.h:2355
virtual void changeEvent(QEvent *)
This event handler can be reimplemented to handle state changes.
Definition: qwidget.cpp:9170
#define Q_OBJECT
Definition: qobjectdefs.h:157
DockWidgetArea
Definition: qnamespace.h:1337
virtual void closeEvent(QCloseEvent *)
This event handler is called with the given event when Qt receives a window close request for a top-l...
Definition: qwidget.cpp:9626
The QMainWindow class provides a main application window.
Definition: qmainwindow.h:63
Definition: qnamespace.h:54
bool isFloating() const
Definition: qdockwidget.h:96
#define Q_FLAGS(x)
Definition: qobjectdefs.h:85
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
bool event(QEvent *)
This is the main event handler; it handles event event.
Definition: qwidget.cpp:8636
#define class
The QPaintEvent class contains event parameters for paint events.
Definition: qevent.h:298
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
#define QT_END_HEADER
Definition: qglobal.h:137
The QCloseEvent class contains parameters that describe a close event.
Definition: qevent.h:364
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64
static int area(const QSize &s)
Definition: qicon.cpp:155