Important: Please read the Qt Code of Conduct -

How to implement MVC using signals and slots

  • I have developed a small application which has ended up with tight coupling where the UI classes contain a lot of business logic. I am wanting to separate the business logic and UI by implementing a controller class to handle this.

    I have thought of a couple of ways I could do this but I just don't think that they're suitable.

    A quick overview of my code base for this question to make sense.

    I have two classes CreateA/CreateB which currently implements the UI and a function called Create() in both which is full of business logic. I want to rename these classes to CreateA_UI/CreateB_UI, and create a Controller class which communicates with two new classes called CreateA/CreateB which will now contain the Create() functions.

    I am struggling to understand how I would structure this to efficiently and effectively use the Qt library, especially signals and slots, to create the MVC pattern and decrease tight coupling.

    Note: I am not using the Qt designer

  • @AaronKelsey would it be worth to look at Qt's model/view architecture, instead of writing your own implementation of the MVC pattern?

  • Moderators

    @AaronKelsey Can you describe what kind of data does the UI collect from the user?the user can do through the UI? What kind of data do they enter

Log in to reply