void QQuickViewInspector::reloadQmlFile(const QHash<QString, QByteArray> &changesHash) { clearComponentCache(); // Reset the selection since we are reloading the main qml setSelectedItems(QList<QQuickItem *>()); QQmlDebugService::clearObjectsFromHash(); QHash<QUrl, QByteArray> debugCache; foreach (const QString &str, changesHash.keys()) debugCache.insert(QUrl(str), changesHash.value(str, QByteArray())); // Updating the cache in engine private such that the QML Data loader // gets the changes from the cache. QQmlEnginePrivate::get(declarativeEngine())->setDebugChangesCache(debugCache); m_sendQmlReloadedMessage = true; // reloading the view such that the changes done for the files are // reflected in view view()->setSource(view()->source()); }
} void AbstractViewInspector::createQmlObject(const QString &qml, QObject *parent, const QStringList &importList, const QString &filename) { if (!parent) return; QString imports; foreach (const QString &s, importList) { imports += s; imports += QLatin1Char('\n'); } QDeclarativeContext *parentContext = declarativeEngine()->contextForObject(parent); QDeclarativeComponent component(declarativeEngine()); QByteArray constructedQml = QString(imports + qml).toLatin1(); component.setData(constructedQml, QUrl::fromLocalFile(filename)); QObject *newObject = component.create(parentContext); if (newObject) reparentQmlObject(newObject, parent); } void AbstractViewInspector::clearComponentCache() { declarativeEngine()->clearComponentCache(); } void AbstractViewInspector::setDesignModeBehavior(bool value)