Connect dynamically created QGraphicsItem to parent
I look for a way to connect QGraphicsItems to its parent by Signal/Slot. I believe I can inherit from QOject, to produce signals.
But my QGraphicsItems are dynamically created.
- The first problem is that I haven't found the method to create any dynamically array of QGraphicsItem derived class,
- and how to connect to its parent please ???
Thanks in advance ;)
Hi and welcome to devnet,
You might be interested by "QGraphicsObject":http://doc.qt.io/qt-5/QGraphicsObject.html
- You have to create them all and add them to your array
- The children should not be responsible of the connection, they should only emit signals so you can change easily what is connected to that signal.
Hope it helps
The anti-spam of the forum don't let me answer !
[EDIT] : Ok, so tx for your answer : is it possible to create a dynamic storage type of QObject class ? With Qvector perhaps ?
The post size have a limit. Did you try to paste a big chunk of code ?
Is something like
@QVector<QObject *> myStorage;@
What you have in mind ?
I would like to do something like
? But it don't seem to be possible ?
No it's not, QObject is not copyable