c++ - Qt : which class should connect() signals and slots - inside or outside the view class? -


After good MVC practices, where should the signal slot connection be? I think it should be outside the visual category, possibly in a dedicated controller class that has points for the visual and model object.

It raises a complexity, although a lot of signal objects can come into view from the square (such as the Qupashbutton). This means that I have to allow the controller to access the members of the view class to break and connect the interface () to see the option () to connect to things (in the class), but then this interface directly with the model class Does, which eliminates the attempt to separate them through MVC.

Object-oriented design has an objective encapsulation. It is irrelevant to the user of the visual category that how you have implemented the class. Design should look at the convenient interface first . You can then do an implementation that uses widget control, another might be, still someone else can use QML, etc. This means that nothing ideal about the inside of the class should be seen at the interface level.

The entire position of the signal slot mechanism, in fact, was the decoupling classes involved in the connections: classes were attached, should not know anything about each other, thus it is a sensible starting point, and in fact it is usually At the right, set up connection outside the class.

To help you in this task, you can take advantage of the signal-signal connection. In QT, a signal is just a method whose machine-generated implementation is done. It has a different name in Metadata, but it is a unique way to do slot. Therefore, when considered as a target of a connection, the signs and slots are equivalent. You can connect the signal to signals Signal-signal connection calls only the target signal method when the source signal method applies.

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -