! Sets the margin \a group of the specified margin \a sides. Margin groups allow synchronizing specified margins across layout elements, see the documentation of \ref QCPMarginGroup. To unset the margin group of \a sides, set \a group to \c nullptr. Note that margin groups only work for margin sides that are set to automatic (\ref setAutoMargins). \see QCP::MarginSide */
| 3394 | \see QCP::MarginSide |
| 3395 | */ |
| 3396 | void QCPLayoutElement::setMarginGroup(QCP::MarginSides sides, QCPMarginGroup *group) |
| 3397 | { |
| 3398 | QVector<QCP::MarginSide> sideVector; |
| 3399 | if (sides.testFlag(QCP::msLeft)) sideVector.append(QCP::msLeft); |
| 3400 | if (sides.testFlag(QCP::msRight)) sideVector.append(QCP::msRight); |
| 3401 | if (sides.testFlag(QCP::msTop)) sideVector.append(QCP::msTop); |
| 3402 | if (sides.testFlag(QCP::msBottom)) sideVector.append(QCP::msBottom); |
| 3403 | |
| 3404 | foreach (QCP::MarginSide side, sideVector) |
| 3405 | { |
| 3406 | if (marginGroup(side) != group) |
| 3407 | { |
| 3408 | QCPMarginGroup *oldGroup = marginGroup(side); |
| 3409 | if (oldGroup) // unregister at old group |
| 3410 | oldGroup->removeChild(side, this); |
| 3411 | |
| 3412 | if (!group) // if setting to 0, remove hash entry. Else set hash entry to new group and register there |
| 3413 | { |
| 3414 | mMarginGroups.remove(side); |
| 3415 | } else // setting to a new group |
| 3416 | { |
| 3417 | mMarginGroups[side] = group; |
| 3418 | group->addChild(side, this); |
| 3419 | } |
| 3420 | } |
| 3421 | } |
| 3422 | } |
| 3423 | |
| 3424 | /*! |
| 3425 | Updates the layout element and sub-elements. This function is automatically called before every |