QGraphicsItem::type() enum value to key
Unsolved
General and Desktop
-
QList<QGraphicsItem*> list_GI = scene->selectedItems(); for (int i=0; i<list_GI.size(); i++) { QMetaEnum metaEnum = QMetaEnum::fromType<QGraphicsItem::anonymous>(); //no member named 'anonymous' in 'QGraphicsItem'; qDebug() << list_GI[i] << metaEnum.valueToKey(list_GI[i]->type()); //qDebug() << list_GI[i] << list_GI[i]->type(); //QGraphicsItem(0x7b6f60, pos=-53,-31, flags=(ItemIsMovable|ItemIsSelectable)) 10 }
For example: change qDebug 2 to QGraphicsPathItem.
-
@sonichy
and your question is? -
You want that your
qDebug
printsQGraphicPathItem
instead of type10
?See
- https://doc.qt.io/qt-5/qgraphicsitem.html#type
- https://doc.qt.io/qt-5/qgraphicsitem.html#anonymous-enum
I guess the problem is, that the enum is not declared as
Q_ENUM
Qt source code:
So
QMetaEnum::fromType(......)
wont work and you cant map thetype
integer to the name directly withfromType
EDIT:
I'm wondering why? :)
Intentionally?Does anyone know more about this? Some public Qt enums are declared with
Q_ENUM
and some just don't...
Qt::GlobalColor
for example works fine and can get mapped perfectly.