Print out graphics item type information
Hello forum,
I am having issues while printing out the graphics item type information. I want to print the verbose information not the numeric one.
Is there any mechanism in Qt to print the graphics item type, something like the following:
Code:
qDebug () << "Item type: " << item->type() << endl;
The above code gives me the numeric value, i would like to have something verbose
Regards
Sajjad
Re: Print out graphics item type information
You can use the typeid operator to print the class name of any object:
Code:
#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;
}
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):
Quote:
17QGraphicsLineItem 17QGraphicsRectItem
12QApplication 7MyClass