Exemplo n.º 1
0
/*!
    \reimp
*/
void QGraphicsLayout::updateGeometry()
{
    Q_D(QGraphicsLayout);
    if (QGraphicsLayout::instantInvalidatePropagation()) {
        d->activated = false;
        QGraphicsLayoutItem::updateGeometry();

        QGraphicsLayoutItem *parentItem = parentLayoutItem();
        if (!parentItem)
            return;

        if (parentItem->isLayout())
            static_cast<QGraphicsLayout *>(parentItem)->invalidate();
        else
            parentItem->updateGeometry();
    } else {
        QGraphicsLayoutItem::updateGeometry();
        if (QGraphicsLayoutItem *parentItem = parentLayoutItem()) {
            if (parentItem->isLayout()) {
                parentItem->updateGeometry();
            } else {
                invalidate();
            }
        }
    }
}
void MMessageBoxViewPrivate::updateLayout()
{
    clearLayout();
    prepareLayout();

    if (centralWidget) {
        contentsLayout->insertItem(0, centralWidget);
    }

    if (textLabel) {
        contentsLayout->insertItem(0, textLabel);
        contentsLayout->setAlignment(textLabel, Qt::AlignCenter);
    }

    if (titleLabel) {
        contentsLayout->insertItem(0, titleLabel);
        contentsLayout->setAlignment(titleLabel, Qt::AlignCenter);
    }

    if (iconImage) {
        contentsLayout->insertItem(0, iconImage);
        contentsLayout->setAlignment(iconImage, Qt::AlignCenter);
    }

    if (!QGraphicsLayout::instantInvalidatePropagation()) {
        /* Update the geometry of the parents immediately. This simply makes the layout have the correct sizehint
         * immediately instead of one frame later, removing a single frame of 'flicker'.
         */
        QGraphicsLayoutItem *item = contents;
        do {
            item->updateGeometry();
        } while( (item = item->parentLayoutItem()) );
    }
}