Fixed takeWidget() function and fixed setWidget() function to handle case if there is already a content widget

This commit is contained in:
Uwe Kindler
2020-04-09 21:44:21 +02:00
parent 9fe1dd6a88
commit 7a17aba42d
2 changed files with 30 additions and 4 deletions

View File

@@ -169,7 +169,12 @@ static ads::CDockWidget* createCalendarDockWidget(QMenu* ViewMenu)
static int CalendarCount = 0;
QCalendarWidget* w = new QCalendarWidget();
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Calendar %1").arg(CalendarCount++));
// The following lines are for testing the setWidget() and takeWidget()
// functionality
DockWidget->setWidget(w);
DockWidget->setWidget(w); // what happens if we set a widget if a widget is already set
DockWidget->takeWidget(); // we remove the widget
DockWidget->setWidget(w); // and set the widget again - there should be no error
DockWidget->setToggleViewActionMode(ads::CDockWidget::ActionModeShow);
DockWidget->setIcon(svgIcon(":/adsdemo/images/date_range.svg"));
ViewMenu->addAction(DockWidget->toggleViewAction());