Serialize QObject to QString
-
Well... I guess in theory you could serialize two objects that have a signal/slot connection, and then store that connection as well. However, I know of no public API to enumerate such connections, so that would be hard to do in practice. Also, I think that you need some additional tricks to fully serialize/deserialize QObjects, because you probably also want to keep their parent/child relationships...
-
[quote author="Gerolf" date="1300560745"]but you can query the meta object for which objects with which slots are connected to which signals. But it could get tricky...[/quote]
Really? Never to old to learn... I looked over the QMetaObject documentation again, and though I find methods to inspect what signals and slots there are, I don't see methods to see what connections have been made. But perhaps I'm looking in the wrong place. I'm sure such API is available somewhere (Qt's internals know about the connections, obviously), but I never stumbled on it in the public parts. Could you show how you would list the current connections for an object?
-
I think it requires access to QObjectPrivate as this is ultimately what maintains the connection list. So I don't think it is possible to get to it with public API (unless I have overlooked something which is certainly possible).
You could hack something yourself by using a wrapper function around QObject::connect() where the wrapper maintains a connection list that you can access and still calls the actual QObject::connect.
-
This is true. For this reason, QDataStream operators are much simpler to write than the equivalent for QTextStream or QXmlStream[Reader|Writer] since you do not have to do the parsing yourself.
Writing operator << for Xml output is easy enough but the operator >> can be more work (I've just done a huge pile of these for work) ;-)
-
[quote author="ZapB" date="1300573424"]I think it requires access to QObjectPrivate as this is ultimately what maintains the connection list. So I don't think it is possible to get to it with public API (unless I have overlooked something which is certainly possible).
[/quote]Hi ZapB, you are right, it's only possible by usage of this class, but it is possible. There is no public API for that. And I think, usually you don't meed such things.
[quote author="ZapB" date="1300573424"]
You could hack something yourself by using a wrapper function around QObject::connect() where the wrapper maintains a connection list that you can access and still calls the actual QObject::connect.[/quote]This would make it even more complex, as mostly you just call connect, without the scope in front. Sou would have to do that for all classes you create.