Qt project structure - consultation needed

I am currently working on a project based on Qt4 / QtCreator. I would like to ask you for advice on how to organize my application.

  • There are 3 separate tools, each of which has its own look. All views are integrated into the main window as tabs. I prepared 3 views: Tool1View, Tool2View, Tool3View

  • Each tool should perform some task caused by user actions. But these are not database related operations (list / add / modify ...) - at least the user is not going to add / modify / write entries in gui elements.

I am going to implement each tool in 2 classes:

  • The first class is ToolXView, which implements the widget and all the tasks associated with gui changes.

  • The second class of ToolX implements the application logic. The member functions of this class are invoked by the View class. Whenever this class needs to update GUI elements, it specializes in specialized functions of the View class. Thus, direct widget calls are not made here.

View class and logical class will be linked together to allow two-way communication.

Now I wonder if this is good. Please advise me based on your experience.

  • I plan to encapsulate a pointer to a logical class as a property of a view class and a pointer to view the class as a property of a logical class. Thus, I plan to integrate them.

  • Should I use signals / slots to provide layout or just call member functions?

  • I need to save some data in a QtSql database. Do I have to provide a separate class to access the database. Or just implement the sepereate member function inside the Logic class?

  • What do you call your classes. Is this circuit good or should I change it?

Thanks for the help. I appreciate your comments.

+7
source share
1 answer

Using mvc architecture is excellent.

1 and 2 - In the link above you will see a UML diagram of the mvc architecture. Regarding this, I connected the presentation signals to the controller methods, and then will call the presentation method from the controller.

3 - Regarding database access, I would add a data access part in your architecture that specializes in data access. You can have an interface to determine the signature of the data access object, and then implement it in a specialized class for the database (this way you can change the location of the data without changing the entire application).

4 - You call a cool name good. But I would go further and name the classes:

  • To view: ClassNameView
  • For controller: ClassNameController
  • For DataAccessObject: ClassNameDAO
  • Model: ClassName (and IClassName for the interface)

Hope that helps

+5
source

All Articles