Skip to content

Commit d0f4ce3

Browse files
Added support to adhere the minimumSizeHint() of the content widget of a dock widget
1 parent 661d0c4 commit d0f4ce3

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

src/DockWidget.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ struct DockWidgetPrivate
8282
QSize ToolBarIconSizeFloating = QSize(24, 24);
8383
bool IsFloatingTopLevel = false;
8484
QList<QAction*> TitleBarActions;
85+
CDockWidget::eMinimumSizeHintMode MinimumSizeHintMode = CDockWidget::MinimumSizeHintFromDockWidget;
8586

8687
/**
8788
* Private data constructor
@@ -424,6 +425,13 @@ void CDockWidget::setToggleViewActionMode(eToggleViewActionMode Mode)
424425
}
425426

426427

428+
//============================================================================
429+
void CDockWidget::setMinimumSizeHintMode(eMinimumSizeHintMode Mode)
430+
{
431+
d->MinimumSizeHintMode = Mode;
432+
}
433+
434+
427435
//============================================================================
428436
void CDockWidget::toggleView(bool Open)
429437
{
@@ -753,7 +761,14 @@ void CDockWidget::setClosedState(bool Closed)
753761
//============================================================================
754762
QSize CDockWidget::minimumSizeHint() const
755763
{
756-
return QSize(60, 40);
764+
if (d->MinimumSizeHintMode == CDockWidget::MinimumSizeHintFromDockWidget || !d->Widget)
765+
{
766+
return QSize(60, 40);
767+
}
768+
else
769+
{
770+
return d->Widget->minimumSizeHint();
771+
}
757772
}
758773

759774

src/DockWidget.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,23 @@ private slots:
189189
ForceNoScrollArea
190190
};
191191

192+
193+
/**
194+
* The mode of the minimumSizeHint() that is returned by the DockWidget
195+
* minimumSizeHint() function.
196+
* To ensure, that a dock widget does not block resizing, the dock widget
197+
* reimplements minimumSizeHint() function to return a very small minimum
198+
* size hint. If you would like to adhere the minimumSizeHint() from the
199+
* content widget, the set the minimumSizeHintMode() to
200+
* MinimumSizeHintFromContent.
201+
*/
202+
enum eMinimumSizeHintMode
203+
{
204+
MinimumSizeHintFromDockWidget,
205+
MinimumSizeHintFromContent
206+
};
207+
208+
192209
/**
193210
* This mode configures the behavior of the toggle view action.
194211
* If the mode if ActionModeToggle, then the toggle view action is
@@ -334,6 +351,13 @@ private slots:
334351
*/
335352
void setToggleViewActionMode(eToggleViewActionMode Mode);
336353

354+
/**
355+
* Configures the minimum size hint that is returned by the
356+
* minimumSizeHint() function.
357+
* \see eMinimumSizeHintMode for a detailed description
358+
*/
359+
void setMinimumSizeHintMode(eMinimumSizeHintMode Mode);
360+
337361
/**
338362
* Sets the dock widget icon that is shown in tabs and in toggle view
339363
* actions

0 commit comments

Comments
 (0)