diff --git a/eqt/ui/UIFormWidget.py b/eqt/ui/UIFormWidget.py index def2939..991f12c 100644 --- a/eqt/ui/UIFormWidget.py +++ b/eqt/ui/UIFormWidget.py @@ -337,7 +337,9 @@ def __init__(self, parent=None): class FormDockWidget(QtWidgets.QDockWidget): def __init__(self, parent=None, title=None): - QtWidgets.QDockWidget.__init__(self, parent) + if title is None: + title = '' + QtWidgets.QDockWidget.__init__(self, title, parent) widget = FormWidget(parent) self.setWidget(widget) if title is not None: diff --git a/examples/remove_widgets_example.py b/examples/remove_widgets_example.py index aebfdf4..185f55d 100644 --- a/examples/remove_widgets_example.py +++ b/examples/remove_widgets_example.py @@ -10,8 +10,7 @@ def __init__(self, parent=None): QtWidgets.QMainWindow.__init__(self, parent) # create a FormDockWidget - dock = UIFormWidget.FormDockWidget(parent=self) - dock.setWindowTitle('Example remove widget') + dock = UIFormWidget.FormDockWidget(parent=self, title='Example remove widget') self.addWidgetsToExampleForm(dock) # add a button to dock to remove user selected widget diff --git a/test/test__formUI_status_test.py b/test/test__formUI_status_test.py index c5539c7..02ba8bb 100644 --- a/test/test__formUI_status_test.py +++ b/test/test__formUI_status_test.py @@ -328,6 +328,12 @@ def setUp(self): self.add_two_widgets() self.layout = self.form.formWidget.uiElements['groupBoxFormLayout'] + def test_form_init_title(self): + """Tests if the FormDialog is created correctly with or without the title argument.""" + FormDialog() + FormDialog(title=None) + FormDialog(title='title') + def test_getWidgetState_returns_QLabel_value(self): """Check that the value of the QLabel is saved to the state""" initial_label_value = 'Label: ' @@ -478,6 +484,12 @@ def setUp(self): self.add_two_widgets() self.layout = self.form.widget().uiElements['groupBoxFormLayout'] + def test_form_init_title(self): + """Tests if the FormDockWidget is created correctly with or without the title argument.""" + FormDockWidget() + FormDockWidget(title=None) + FormDockWidget(title='title') + def test_getWidgetState_returns_QLabel_value(self): """Check that the value of the QLabel is saved to the state""" initial_label_value = 'test label'