GammaRay API Documentation  2.11.0
Classes | Signals | Public Member Functions | Static Public Member Functions | List of all members
GammaRay::Probe Class Reference

Central entity of GammaRay: The probe is tracking the Qt application under test. More...

#include <probe.h>

Inheritance diagram for GammaRay::Probe:
Inheritance graph
[legend]

Signals

void aboutToDetach ()
 
void nonQObjectSelected (void *object, const QString &typeName)
 
void objectCreated (QObject *obj)
 Emitted for newly created QObjects. More...
 
void objectDestroyed (QObject *obj)
 Emitted for destroyed objects. More...
 
void objectReparented (QObject *obj)
 
void objectSelected (QObject *object, const QPoint &pos)
 Emitted when the user selected object at position pos in the probed application.
 

Public Member Functions

const QVector< QObject * > & allQObjects () const
 Returns a list of all QObjects we know about. More...
 
void discoverObject (QObject *object)
 Notify the probe about QObjects your plug-in can discover by using information about the types it can handle. More...
 
bool filterObject (QObject *obj) const
 Determines if the specified QObject belongs to the GammaRay Probe or Window. More...
 
void installGlobalEventFilter (QObject *filter)
 Install a global event filter. More...
 
bool isValidObject (const QObject *obj) const
 Check whether obj is still valid. More...
 
MetaObjectRegistry * metaObjectRegistry () const
 
bool needsObjectDiscovery () const
 Returns true if we haven't been able to track all objects from startup, ie. More...
 
SourceLocation objectCreationSourceLocation (QObject *object) const
 Returns the source code location object was created at. More...
 
Execution::Trace objectCreationStackTrace (QObject *object) const
 Returns the entire stack trace for the creation of object. More...
 
QAbstractItemModelobjectListModel () const
 Returns the object list model. More...
 
QAbstractItemModelobjectTreeModel () const
 Returns the object tree model. More...
 
ProblemCollector * problemCollector () const
 
void registerModel (const QString &objectName, QAbstractItemModel *model)
 Register a model for remote usage. More...
 
void registerSignalSpyCallbackSet (const SignalSpyCallbackSet &callbacks)
 Register a signal spy callback set. More...
 
void selectObject (QObject *object, const QPoint &pos=QPoint())
 Notify the probe about the user selecting one of "your" objects via in-app interaction. More...
 
void selectObject (QObject *object, const QString &toolId, const QPoint &pos=QPoint())
 
void selectObject (void *object, const QString &typeName)
 Notify the probe about the user selecting one of "your" objects. More...
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
bool blockSignals (bool block)
 
const QObjectList & children () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo () const const
 
void dumpObjectInfo ()
 
void dumpObjectTree () const const
 
void dumpObjectTree ()
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
virtual int qt_metacall (QMetaObject::Call, int, void **)
 
virtual void * qt_metacast (const char *)
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
QThreadthread () const const
 

Static Public Member Functions

static Probeinstance ()
 Returns the current instance of the probe. More...
 
static bool isInitialized ()
 Returns true if the probe is initialized, false otherwise.
 
static QMutexobjectLock ()
 Lock this to check the validity of a QObject and to access it safely afterwards.
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 

Additional Inherited Members

- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 
- Properties inherited from QObject
 objectName
 

Detailed Description

Central entity of GammaRay: The probe is tracking the Qt application under test.

Note
The Probe lifetime is strongly coupled with the QCoreApplication lifetime, if there's no QCoreApplication instance, then there's no probe.

To get a hold of the probe, call Probe::instance()

Member Function Documentation

const QVector<QObject*>& GammaRay::Probe::allQObjects ( ) const

Returns a list of all QObjects we know about.

Note
This getter can be used without the object lock. Do acquire the object lock and check the pointer with isValidObject though, before dereferencing any of the QObject pointers.
void GammaRay::Probe::discoverObject ( QObject object)

Notify the probe about QObjects your plug-in can discover by using information about the types it can handle.

Only use this if needsObjectDiscovery() returns true to maximise performance.

See also
needsObjectDiscovery()
Since
2.0
bool GammaRay::Probe::filterObject ( QObject obj) const

Determines if the specified QObject belongs to the GammaRay Probe or Window.

These objects should not be tracked or shown to the user, hence must be explictly filtered.

Parameters
objis a pointer to a QObject instance.
Returns
true if the specified QObject belongs to the GammaRay Probe or Window; false otherwise.
void GammaRay::Probe::installGlobalEventFilter ( QObject filter)

Install a global event filter.

Use this rather than installing the filter manually on QCoreApplication, this will filter out GammaRay-internal events and objects already for you.

static Probe* GammaRay::Probe::instance ( )
static

Returns the current instance of the probe.

Note
You must hold the object lock when using the probe's object tracking functionality.
See also
objectLock()
bool GammaRay::Probe::isValidObject ( const QObject obj) const

Check whether obj is still valid.

Note
The objectLock must be locked when this is called!
bool GammaRay::Probe::needsObjectDiscovery ( ) const

Returns true if we haven't been able to track all objects from startup, ie.

usually when attaching at runtime. If this is the case, we try to discover QObjects by walking the hierarchy, starting from known singletons, and by watching out for unknown receivers of events. This is far from complete obviously, and plug-ins can help finding more objects, using specific knowledge about the types they are responsible for.

Connect to the objectAdded(QObject*) signal on probe(), and call discoverObject(QObject*) for "your" objects.

Since
2.5
void GammaRay::Probe::objectCreated ( QObject obj)
signal

Emitted for newly created QObjects.

Note:

  • This signal is always emitted from the thread the probe exists in.
  • The signal is emitted delayed enough for the QObject to have been fully constructed, i.e. on the next event loop re-entry.
  • The signal is not emitted if the object has been destroyed completely again meanwhile, e.g. for objects that only existed on the stack.
  • For objects created and destroyed in other threads, this signal might be emitted after its dtor has been entered (in case of short-lived objects), but before it has been finished. At this point the dtor might have already emitted the destroyed() signal and informed smart pointers about the destruction. This means you must not rely on any of this for object lifetime tracking for objects from other threads. Use objectDestroyed() instead.
  • Do not put obj into a QWeakPointer, even if it's exclusively handled in the same thread as the Probe instance. Qt4 asserts if target code tries to put obj into a QSharedPointer afterwards.
  • The objectLock() is locked.
SourceLocation GammaRay::Probe::objectCreationSourceLocation ( QObject object) const

Returns the source code location object was created at.

Execution::Trace GammaRay::Probe::objectCreationStackTrace ( QObject object) const

Returns the entire stack trace for the creation of object.

void GammaRay::Probe::objectDestroyed ( QObject obj)
signal

Emitted for destroyed objects.

Note:

  • This signal is emitted from the thread the probe exists in.
  • The signal is emitted from the end of the QObject dtor, dereferencing obj is no longer safe at this point.
  • In a multi-threaded application, this signal might reach you way after obj has been destroyed, see isValidObject() for a way to check if the object is still valid before accessing it.
  • The objectLock() is locked.
QAbstractItemModel* GammaRay::Probe::objectListModel ( ) const

Returns the object list model.

Returns
a pointer to a QAbstractItemModel instance.
QAbstractItemModel* GammaRay::Probe::objectTreeModel ( ) const

Returns the object tree model.

Returns
a pointer to a QAbstractItemModel instance.
void GammaRay::Probe::registerModel ( const QString objectName,
QAbstractItemModel model 
)

Register a model for remote usage.

Parameters
objectNameUnique identifier for the model, typically in reverse domain notation.
modelThe model to register.
void GammaRay::Probe::registerSignalSpyCallbackSet ( const SignalSpyCallbackSet callbacks)

Register a signal spy callback set.

Signal indexes provided as arguments are mapped to method indexes, ie. argument semantics are the same with Qt4 and Qt5.

Since
2.2
void GammaRay::Probe::selectObject ( QObject object,
const QPoint pos = QPoint() 
)

Notify the probe about the user selecting one of "your" objects via in-app interaction.

If you know the exact position the user interacted with, pass that in as pos.

Since
2.0
void GammaRay::Probe::selectObject ( void *  object,
const QString typeName 
)

Notify the probe about the user selecting one of "your" objects.

Since
2.1

Klarälvdalens Datakonsult AB (KDAB)
"The Qt Experts"
https://www.kdab.com/
GammaRay
Qt-application inspection and manipulation tool
https://www.kdab.com/gammaray/