Search code examples
c++qtqprogressbar

What is the proper way to forward QProgressBar updates through classes in the logic layer?


I'm using a QProgressBar and have already figured out how to send the progress from a specific class in the logic layer with this procedure:

  • setting up the connection in the view-layer class.
  • creating the signal signal in the logic-layer class.
  • modifying the logic-layer class such that it is a QObject.
  • calling QObject as the base-class class constructor for the logic-layer.

Now, I would like my specific class in the logic-layer to send the progress through another class.

For example:

  1. Class A (in the view-layer): create connection for the progress in class B.
  2. Class B (in the logic-layer): create connection for the progress in class C.
  3. Class C: updating the progress so it can be seen in class A (view-layer).

I tried to imitate this procedure for using a connection and signal from class B to C, but it doesn't seem to be working.

Any answer will be appreciated


Solution

  • OK I figured it out. What I did is to send the peogress-bar object from MainWindow (view layer) to LogicClass1 (logic layer) and then to connect it with SIGNAL to LogicClass2.

    Of course, LogicClass1 should inherit from QObject as mentioned above-

    class LogicClass1 : public QObject
    {
    
        Q_OBJECT
       .
       .
       .
    

    And most important thing (because I forgot about it): right click on the project and "Run qmake" :)