class RefreshDeferrer

Helper class for deferred refreshing in Widgets.

This class can handle the logic necessary to defer the refreshing of widgets when they are not visible. It contains an optional RefreshDeferrerAccumulator, which can be used to accumulate incoming events while refreshing is deferred.

Example (don’t write it like this in practice, use the convenience methods in CutterDockWidget):

// in the constructor of a widget
this->refreshDeferrer = new RefreshDeferrer(new ReplacingRefreshDeferrerAccumulator(false), this);
connect(this->refreshDeferrer, &RefreshDeferrer::refreshNow, this, [this](MyParam *param) {
     // We attempted a refresh some time before, but it got deferred.
     // Now the RefreshDeferrer tells us to do the refresh and gives us the accumulated param.

// ...

void MyWidget::doRefresh(MyParam param)
     if (!this->refreshDeferrer->attemptRefresh(new MyParam(param))) {
         // We shouldn't refresh right now.
         // The RefreshDeferrer takes over the param we passed it in attemptRefresh()
         // and gives it to the ReplacingRefreshDeferrerAccumulator.
     // do the actual refresh depending on param

Public Functions

RefreshDeferrer(RefreshDeferrerAccumulator *acc, QObject *parent)

  • acc -

    The accumulator (can be nullptr). The RefreshDeferrer takes the ownership!

bool attemptRefresh(RefreshDeferrerParams params)
void registerFor(CutterDockWidget *dockWidget)


signal RefreshDeferrer::refreshNow