[SOLVED] Signal from QList Object to Slot from parent
-
I want to relay/concatenate a signal from an object I put into a QList to its parent to trigger a redraw of the parent object. But where to put the connect()?
@
void Desktop::addTray(Tray tray) {
trayList.append(tray);
}void Tray::setColor(int number, QColor color) {
pointList[number].setColor(color);
emit dataChanged();
}
@If I append a new tray object to the desktop I copy the object not a pointer to it. So If I would write the connect() after line 2, I wouldn't connect to the object within the trayList.
-
since Tray is QObject subclass, "it can't be copied":http://qt-project.org/doc/qt-4.8/qobject.html#no-copy-constructor-or-assignment-operator
when you connect, you connect with the original object you created -
You're right.. I didn't inherit from QObject. I have to change my QList and store pointers, not objects.
But how can I prevent that the objects get deleted or freed?
The Tray-Objects where created dynamically while parsing a file. If the parser function is exited, every Tray object will be deleted or freed.
How can I prevent them from deletion? I thought on "static" but I want to delete the Tray objects when the QList gets cleared which would be possible with static declaration.