Updating the Qt widget later, but when?

I would like to know what exactly happens when I call the QWidget update () method.
Here is the documentation:

http://doc.qt.digia.com/4.5/qwidget.html#update

This function does not cause immediate repainting; instead, it assigns a drawing event to be processed when Qt returns to the main event loop. This allows Qt to optimize for more speed and less flicker than call to repaint () does.

From the Qt source code, you can see that QUpdateLaterEvent is created and published with the type QEvent :: UpdateLater

In this part of the documentation http://doc.qt.digia.com/4.5/qevent.html

QEvent :: UpdateLater: the widget must be queued to be repainted later.

What does "later time" mean?
Are my all queued signals and events in the event queue processed before paint?

Thanks
Gabor

+5
source share
2 answers

After checking the source code of QWidget :: update (), I found that it calls this method in src/gui/kernel/qwidget.cpp:9544:

void QWidget::update(const QRect &rect)
{
    if (!isVisible() || !updatesEnabled() || rect.isEmpty())
        return;

    if (testAttribute(Qt::WA_WState_InPaintEvent)) {
        QApplication::postEvent(this, new QUpdateLaterEvent(rect));
        return;
    }

    if (hasBackingStoreSupport()) {
        QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
        if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore)
            tlwExtra->backingStore->markDirty(rect, this);
    } else {
        d_func()->repaint_sys(rect);
    }
}

As you can see, it is QUpdateLaterEventpublished only if update () is already called from the paintEvent () method.

You can also check the source QWidget::repaint(const QRect &rect)on line 9456 - it lacks testAttribute(Qt::WA_WState_InPaintEvent)check.

EDIT

QUpdateLaterEvent Qt::NormalEventPriority, (. src/corelib/kernel/qcoreapplication.cpp:971 :1003). , compressEvent, .

, : QUpdateLaterEvent , , .

+4

== Qt. , .

+4

All Articles