You can use the typeid operator to print the class name of any object:
#include <QApplication>
#include <QtCore>
#include <QDebug>
#include <QtGui>
#include <typeinfo>
class MyClass
{
};
int main(int argc, char **argv) {
MyClass m;
qDebug() << typeid(line).name() << typeid(rect).name();
qDebug() << typeid(app).name() << typeid(m).name();
return 0;
}
#include <QApplication>
#include <QtCore>
#include <QDebug>
#include <QtGui>
#include <typeinfo>
class MyClass
{
};
int main(int argc, char **argv) {
QGraphicsLineItem line;
QGraphicsRectItem rect;
QApplication app(argc,argv);
MyClass m;
qDebug() << typeid(line).name() << typeid(rect).name();
qDebug() << typeid(app).name() << typeid(m).name();
return 0;
}
To copy to clipboard, switch view to plain text mode
remember to #include <typeinfo>. The output depends on the compiler, so use this carefully (don't make any assumptions about this value, just use it for your information only):
17QGraphicsLineItem 17QGraphicsRectItem
12QApplication 7MyClass
Bookmarks