10#include <private/qqmldebugservice_p.h>
11#include <private/qqmlproperty_p.h>
12#include <private/qqmlvaluetype_p.h>
14#include <QtCore/qmetaobject.h>
15#include <QtCore/qdebug.h>
44 QMetaProperty m_property;
46 QQmlExpression *m_expr;
57 QObject::connect(m_expr, &QQmlExpression::valueChanged,
58 this, &QQmlWatchProxy::notifyValueChanged);
61QQmlWatchProxy::QQmlWatchProxy(
int id, QObject *object,
int debugId,
const QMetaProperty &prop,
71 static int refreshIdx = -1;
73 refreshIdx = QQmlWatchProxy::staticMetaObject.indexOfMethod(
"notifyValueChanged()");
75 if (prop.hasNotifySignal())
76 QQmlPropertyPrivate::connect(m_object, prop.notifySignalIndex(),
this, refreshIdx);
83 v = m_expr->evaluate();
85 v = m_property.read(m_object);
86 emit m_watch->propertyChanged(m_id, m_debugId, m_property, v);
97 QObject *object = QQmlDebugService::objectForId(debugId);
99 int propCount = object->metaObject()->propertyCount();
100 for (
int ii=0; ii<propCount; ii++)
101 addPropertyWatch(id, object, debugId, object->metaObject()->property(ii));
109 QObject *object = QQmlDebugService::objectForId(debugId);
111 int index = object->metaObject()->indexOfProperty(property.constData());
113 addPropertyWatch(id, object, debugId, object->metaObject()->property(index));
120bool QQmlWatcher::addWatch(
int id, quint32 objectId,
const QString &expr)
122 QObject *object = QQmlDebugService::objectForId(objectId);
123 QQmlContext *context = qmlContext(object);
125 QQmlExpression *exprObj =
new QQmlExpression(context, object, expr);
126 exprObj->setNotifyOnValueChanged(
true);
128 exprObj->setParent(proxy);
129 m_proxies[id].append(proxy);
130 proxy->notifyValueChanged();
138 if (!m_proxies.contains(id))
141 QList<QPointer<QQmlWatchProxy> > proxies = m_proxies.take(id);
146void QQmlWatcher::addPropertyWatch(
int id, QObject *object, quint32 debugId,
const QMetaProperty &property)
149 m_proxies[id].append(proxy);
151 proxy->notifyValueChanged();
156#include <qqmlwatcher.moc>
158#include "moc_qqmlwatcher.cpp"
QQmlWatchProxy(int id, QQmlExpression *exp, int debugId, QQmlWatcher *parent=nullptr)
bool addWatch(int id, quint32 objectId)
bool addWatch(int id, quint32 objectId, const QByteArray &property)
Combined button and popup list for selecting options.