@@ -152,26 +152,12 @@ private slots:
152152 StateFloating
153153 };
154154
155- /* *
156- * Use the layout flags to configure the layout of the dock widget.
157- * The content of a dock widget should be resizable do a very small size to
158- * prevent the dock widget from blocking the resizing. To ensure, that a
159- * dock widget can be resized very well, it is better to insert the content+
160- * widget into a scroll area. Enable the WithScrollArea
161- * feature to use this feature. If your content widget is already in a
162- * scroll area or if it is a derived class like QTableView, the you should
163- * disable the WithScrollArea flag.
164- * Often dock widgets need a ToolBar for control of operations in the dock
165- * widget. Use the WithToolBar feature to enable a tool bar that is placed
166- * on top of the dock widget content. If this flag is disabled, the toolBar()
167- * function returns a nullptr.
168- */
169- enum LayoutFlag
155+ enum eInsertMode
170156 {
171- WithScrollArea = 0x01 ,
172- WithTopToolBar = 0x02
157+ AutoScrollArea,
158+ ForceScrollArea,
159+ ForceNoScrollArea
173160 };
174- Q_DECLARE_FLAGS (LayoutFlags, LayoutFlag)
175161
176162 /* *
177163 * This mode configures the behavior of the toggle view action.
@@ -201,8 +187,7 @@ private slots:
201187 * by calling setObjectName() after construction.
202188 * Use the layoutFlags to configure the layout of the dock widget.
203189 */
204- CDockWidget (const QString &title, QWidget* parent = 0 ,
205- LayoutFlags layoutFlags = 0 );
190+ CDockWidget (const QString &title, QWidget* parent = 0 );
206191
207192 /* *
208193 * Virtual Destructor
@@ -216,8 +201,22 @@ private slots:
216201
217202 /* *
218203 * Sets the widget for the dock widget to widget.
204+ * The InsertMode defines how the widget is inserted into the dock widget.
205+ * The content of a dock widget should be resizable do a very small size to
206+ * prevent the dock widget from blocking the resizing. To ensure, that a
207+ * dock widget can be resized very well, it is better to insert the content+
208+ * widget into a scroll area or to provide a widget that is already a scroll
209+ * area or that contains a scroll area.
210+ * If the InsertMode is AutoScrollArea, the DockWidget tries to automatically
211+ * detect how to insert the given widget. If the widget is derived from
212+ * QScrollArea (i.e. an QAbstractItemView), then the widget is inserted
213+ * directly. If the given widget is not a scroll area, the widget will be
214+ * inserted into a scroll area.
215+ * To force insertion into a scroll area, you can also provide the InsertMode
216+ * ForceScrollArea. To prevent insertion into a scroll area, you can
217+ * provide the InsertMode ForceNoScrollArea
219218 */
220- void setWidget (QWidget* widget);
219+ void setWidget (QWidget* widget, eInsertMode InsertMode = AutoScrollArea );
221220
222221 /* *
223222 * Returns the widget for the dock widget. This function returns zero if
@@ -306,17 +305,30 @@ private slots:
306305 void setIcon (const QIcon& Icon);
307306
308307 /* *
309- * Returns tzhe icon that has been assigned to the dock widget
308+ * Returns the icon that has been assigned to the dock widget
310309 */
311310 QIcon icon () const ;
312311
313312 /* *
314313 * If the WithToolBar layout flag is enabled, then this function returns
315314 * the dock widget toolbar. If the flag is disabled, the function returns
316315 * a nullptr.
316+ * This function returns the dock widget top tool bar.
317+ * If no toolbar is assigned, this function returns nullptr. To get a vaild
318+ * toolbar you either need to create a default empty toolbar via
319+ * createDefaultToolBar() function or you need to assign you custom
320+ * toolbar via setToolBar().
317321 */
318322 QToolBar* toolBar () const ;
319323
324+ /* *
325+ * If you would like to use the default top tool bar, then call this
326+ * function to create the default tool bar.
327+ * After this function the toolBar() function will return a valid toolBar()
328+ * object.
329+ */
330+ QToolBar* createDefaultToolBar ();
331+
320332 /* *
321333 * Assign a new tool bar that is shown above the content widget.
322334 * The dock widget will become the owner of the tool bar and deletes it
0 commit comments