Skip to content

Adding actions after MainWindow instantiated doesn't set keybindings (Qt) #244

@kevinyamauchi

Description

@kevinyamauchi

Hello! I noticed that when I add actions after the MainWindow is instantiated, the keybindings do seem to be added. Is this the expected behavior? If so, is there something I am supposed to do after to add the keybindings? If not, would it be possible for this to be added?

  • app_model version: 0.3.1
  • Backend: Qt
  • OS: Mac OS

Thanks!

To reproduce:

  1. Run the model_app.py demo script. The key bindings should work.
  2. Move the for loop for registering the actions to after the window instantiation. The app still launches and the actions are visible in the menu and work when pressed. However, the keybindings no longer work.
if __name__ == "__main__":
  app = Application(name="my_app")
  qapp = QApplication.instance() or QApplication([])
  qapp.setAttribute(Qt.ApplicationAttribute.AA_DontShowIconsInMenus)
  main_win = MainWindow(app=app)
  
  # adding actions now after the main window created
  for action in ACTIONS:
      app.register_action(action)
  
  app.injection_store.register_provider(lambda: main_win, MainWindow)
  main_win.show()
  qapp.exec_()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions