Is there a list of QGraphicsItem types?
-
This is probably a rather nooby question, but for the life of me I can't find a page which lists all the type values for QGraphicsItems.
i.e. values returned fromQGraphicsItem::type()Of course I know I can extract a list from qgraphicsitem.h but isn't it formally documented somewhere?
Having searched the forum, I only see mention ofqgraphicsitem_cast, andQGraphicsItem::Type.Any help much appreciated!
-
If you want to distinguish between your custom types and use qgraphicsitem_cast<> you have to define unique id's returned by type().
-
No there is not. But why do you need it?
-
@Christian-Ehrlicher I'm trying to identify all the objects in the scene, and avoid placing a context menu over certain items. Although perhaps I should know what's in my scene and I have this back to front. But there are many items small & big.
-
@Christian-Ehrlicher I'm trying to identify all the objects in the scene, and avoid placing a context menu over certain items. Although perhaps I should know what's in my scene and I have this back to front. But there are many items small & big.
@idlefrog
If you use woboq to look at the source forQGraphicsItem::type()you'll come across e.g.class Q_WIDGETS_EXPORT QGraphicsEllipseItem enum { Type = 4 }; int type() const override; int QGraphicsEllipseItem::type() const { return Type; }in various files. So it's done via an "anonymous
enum", defined in each derived class. I can't see anything which gathers those all together for you. -
But why you can't simply compare the type() integer with the ones you want to be able to show a context menu and use e.g. QGraphicsEllipseItem::Type instead an integer?
-
But why you can't simply compare the type() integer with the ones you want to be able to show a context menu and use e.g. QGraphicsEllipseItem::Type instead an integer?
@Christian-Ehrlicher Well, I don't know what they are, or where they are made, and they don't have any object name. I'm trying to reverse engineer in a way. It seems as if I will have to add 'type()' methods to all the prime suspects, but it's not a systematic approach.
Which makes me think that perhaps my approach is all wrong here.
Anyhow, your help is much appreciated! Any suggestions are welcome :) -
@idlefrog
If you use woboq to look at the source forQGraphicsItem::type()you'll come across e.g.class Q_WIDGETS_EXPORT QGraphicsEllipseItem enum { Type = 4 }; int type() const override; int QGraphicsEllipseItem::type() const { return Type; }in various files. So it's done via an "anonymous
enum", defined in each derived class. I can't see anything which gathers those all together for you. -
@Christian-Ehrlicher Well, I don't know what they are, or where they are made, and they don't have any object name. I'm trying to reverse engineer in a way. It seems as if I will have to add 'type()' methods to all the prime suspects, but it's not a systematic approach.
Which makes me think that perhaps my approach is all wrong here.
Anyhow, your help is much appreciated! Any suggestions are welcome :)@idlefrog said in Is there a list of QGraphicsItem types?:
It seems as if I will have to add 'type()' methods to all the prime suspect
You're aware that such a function already exists? Still don't understand the problem.
-
@idlefrog said in Is there a list of QGraphicsItem types?:
It seems as if I will have to add 'type()' methods to all the prime suspect
You're aware that such a function already exists? Still don't understand the problem.
@Christian-Ehrlicher Sorry, I probably am not being that clear. But I have a number of derived classes from QGraphicsItem, but even with the debugger can't identify them. So if I add 'type()' methods to those, I should start to identify the classes that I'm clicking on, and were they are. But knowing their base type is of course a start.
-
If you want to distinguish between your custom types and use qgraphicsitem_cast<> you have to define unique id's returned by type().
-
If you want to distinguish between your custom types and use qgraphicsitem_cast<> you have to define unique id's returned by type().
@Christian-Ehrlicher Thanks... am just starting to do that. Although I wondering how best to allocate the ID's without creating some god enum object. So I may just for settle on picking unique/random IDs for just those that I suspect are under the cursor.
-
Noone stops you from defining an enum by yourself starting with Qt::UserType.