The correct solution in my scenario is to install an event filter.
void
SplashScreenListModel::append(const QString& name, QObject* item) {
// Get dynamic property initialized value
// If the returned variant is invalid, the property is not set yet
QVariant v = item->property("initialized");
bool initStatus = false;
if (v.isValid() && v.value<bool>())
initStatus = true;
s_instance->beginInsertRows(QModelIndex(), s_instance->m_data.length(),
s_instance->m_data.length());
s_instance->m_data.append(SPDataItem(name, item, initStatus));
s_instance->endInsertRows();
// Set name for identification in slot
item->setObjectName(name);
// Install eventfilter
item->installEventFilter(s_instance.get());
}
bool
SplashScreenListModel::eventFilter(QObject* obj, QEvent* event) {
if (event->type() != QEvent::DynamicPropertyChange)
return QObject::eventFilter(obj, event); // Default processing
// We have a QDynamicPropertyChangeEvent at hand
QDynamicPropertyChangeEvent* pc =
static_cast<QDynamicPropertyChangeEvent*>(event);
// Not the correct dynamic property
if (pc->propertyName() != "initialized")
return QObject::eventFilter(obj, event); // Default processing
// Value is false
if (!obj->property(pc->propertyName()).value<bool>())
return true;
QModelIndex idx = indexByName(obj->objectName());
setData(idx, true, SplashScreenListModel::InitializationRole);
return true;
}