Skip to content

Question: How to properly use action callbacks in a multi-file app #253

Description

@ndxmrb

Hi,
currently I'm trying to create an app using a multi-file approach. I've seen the examples (one file and multi file), but I find it difficult to translate some of the workings from one file to multi-file.

Broadly speaking, I'm trying to decouple the application as much as possible from the GUI. Therefore, I have e.g. a controller instance in the app_model Application instance. With the controller I can e.g. load a file, modify it, save it etc. without ever touching Qt.

  1. Is having the "business logic" (if you can call it that) on the Application instance the recommended way of doing it?

Now when I have an Action callback operating on the main window (e.g. mainWindow.open()) in the single file approach we can just use callback=mainWindow.open. In the multi-file approach example we can't because of circular imports (but can use QApplication to get the window).

  1. How can I connect a callback to something like mainWindow.open? I tried using a provider there but that gets called when there is no mainWindow yet.

It'd really help, if the same functionality of the single file app was replicated in the multi file app example.

Thanks

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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