-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdebugutils.cpp
More file actions
28 lines (25 loc) · 817 Bytes
/
debugutils.cpp
File metadata and controls
28 lines (25 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "debugutils.h"
#include <QMetaObject>
#include <QMetaProperty>
#include <QVariant>
#include <QByteArray>
DebugUtils::DebugUtils(QObject *parent) :
QObject(parent)
{
}
QString DebugUtils::toString(const QObject *o)
{
QString result("\nDumping object\n");
if ( !o )
return result;
const QMetaObject *meta = o->metaObject();
for( int i=0; i<meta->propertyCount(); i++ ) {
const char * propertyName = meta->property(i).name();
QVariant value = o->property(propertyName);
result += "\t" + QString(propertyName) + ": " + value.toString() + "\n";
}
foreach(QByteArray dynamicPropery, o->dynamicPropertyNames()) {
result += "\t" + QString(dynamicPropery) + ": " + o->property(dynamicPropery.data()).toString() + "\n";
}
return result;
}