title: Qt resize child rectangles
body: <p>Working on a school project, but I'm completely stuck. I have to write a paint application, in which you can draw Rectangles &amp; Ellipses, select them, group them, move and resize them. After that I have to start implementing several design patterns.</p>
  <p>I have to following problem. I have an abstract class Figure which inherits QRect, then there are the classes Rectangle, Ellipse and Group which all inherit the Figure class.</p>
  <p>I am able to resize a single figure (ellipse or shape), by clicking on the corner of a selected shape, but the problem is resizing a group which contains several other figures (group, rectangle or ellipse), they have to resize relatively to their parent figure:</p>
  <p><strong>Mouse move event</strong></p>
  <pre><code>void MainWindow::OnPaintBoxMouseMove(PaintBox *sender, QMouseEvent *event) {
      //Mouse move event based on which tool is selected
      switch(tool){
          //When rectangle tool is selected, update rectangle size to mouse position
          //in command
          case rectangle: {
              tempCmd-&gt;update(event-&gt;pos());
              break;
          }
          //When ellipse tool is selected, update ellipse size to mouse position
          //in command
          case ellipse: {
              tempCmd-&gt;update(event-&gt;pos());
              break;
          }
          //When select tool is selected
          case select: {
              //If moving is selected, update shape in command
              if (moving){
                  sRect-&gt;move(startPoint,event-&gt;pos());
                  tempCmd-&gt;update(event-&gt;pos());
                  startPoint = event-&gt;pos();
              }
              //If resizing is selected, update shape in command
              else if (resizing){
                  sRect-&gt;resize(startPoint,event-&gt;pos());
                  tempCmd-&gt;update(event-&gt;pos());
                  startPoint = event-&gt;pos();
              }
              //Otherwise update size of selection rectangle
              else if (sRect != nullptr) {
                  sRect-&gt;updateDimensions(event-&gt;pos());
              }
              break;
          }
      }
      paintBox-&gt;update();
  }
  </code></pre>
  <p><strong>Resize method in resize command</strong>
  <em>called 'update' here</em></p>
  <pre><code>void ResizeCmd::update(QPoint mousePosition) {
      switch (direction){
          case 1: {
              _figure-&gt;setTopLeft(_figure-&gt;topLeft()+mousePosition-startMousePosition);
              break;
          }
          case 2: {
              _figure-&gt;setTopRight(_figure-&gt;topRight()+mousePosition-startMousePosition);
              break;
          }
          case 3: {
              _figure-&gt;setBottomLeft(_figure-&gt;bottomLeft()+mousePosition-startMousePosition);
              break;
          }
          case 4: {
              _figure-&gt;setBottomRight(_figure-&gt;bottomRight()+mousePosition-startMousePosition);
              break;
          }
      }
      startMousePosition = mousePosition;
  }
  </code></pre>
  <p>So the question is, how am I going to implement the resize method in the group class, which may contain other child groups as well?</p>