Skip to content

Set title correctly in the class FormDockWidget #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion eqt/ui/UIFormWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions examples/remove_widgets_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions test/test__formUI_status_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: '
Expand Down Expand Up @@ -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'
Expand Down