Skip to content

Inconsistent UI state initialization in QtAutoPlugin (Qt6) #829

@dev-jam

Description

@dev-jam

Hi Sebastiaan, I had some problems with correctly setting the state of items in a plugin. I created this bug report with gemini.

Description:
When developing a plugin using QtAutoPlugin in OpenSesame 4.0+, there is an inconsistency in how the enabled state of widgets is handled during initialization.

While QLineEdit widgets correctly maintain an setEnabled(False) state set within init_edit_widget(), other widgets like QComboBox and QCheckBox appear to be "reset" to Enabled=True by the framework immediately after init_edit_widget() finishes.

Steps to reproduce:

  1. Create a plugin based on QtAutoPlugin.
  2. In init_edit_widget(), set several widgets to setEnabled(False) based on the state of a "master" checkbox.
  3. Observe that QLineEdit objects are correctly disabled when the UI loads.
  4. Observe that QComboBox and QCheckBox objects remain enabled, despite widget.isChecked() returning the expected value and the manual setEnabled(False) call being executed.

Current workaround:
The only way to force the correct state is by using a QTimer.singleShot(0, self.update_ui_states) to defer the setEnabled calls until after the framework has completed its internal setup/variable binding.

Expected behavior:
The framework should respect the enabled state set by the developer in init_edit_widget(), or provide a specific hook that is called after variable binding is complete but before the UI is shown to the user.

Environment:

  • OpenSesame version: 4.1.8
  • Operating System: Debian Trixie

Example snippet:

class MyPlugin(QtAutoPlugin):
    """ 
    Minimal example showing that QLineEdit respects setEnabled(False) 
    during init, but QComboBox and QCheckBox do not.
    """

    def init_edit_widget(self):
        super().init_edit_widget()
        
        # Assume self.checkbox_master is the trigger (default Unchecked)
        master_state = self.checkbox_master.isChecked() # Returns False
        
        # 1. This WORKS: LineEdit will be disabled on startup
        self.line_edit_test.setEnabled(master_state)
        
        # 2. This FAILS: ComboBox will be enabled on startup despite master_state being False
        self.combobox_test.setEnabled(master_state)
        
        # 3. This FAILS: CheckBox will be enabled on startup
        self.checkbox_test.setEnabled(master_state)

        # Connections work fine once the user starts interacting:
        self.checkbox_master.stateChanged.connect(self.combobox_test.setEnabled)

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions