The Object Manager

11 views
Skip to first unread message

Simon Gemmell

unread,
Jan 30, 2013, 11:37:01 PM1/30/13
to qtil...@googlegroups.com
So I kind of like the idea of using a global pool of static objects for things like Qt models (those derived from QAbstractItemModel) - it just means you don't need to pass them around through all these widgets that don't use them so they can be used deep down (e.g. in an autocompleter).

However the Qtilities object manager doesn't seem to be meant for that. When I originally saw it I thought it would mean I could register any QObject with a handle and then get access to it from wherever I please by just knowing the handle (i.e. a globally accessible enum). But it looks like you can't get them back out of the object manager without going through the whole lot and doing a qobject_cast.

In any case, I will implement a specific use case for my scenario (with static SetXyzModel and GetXyzModel functions) but let me know if I've got something wrong or misread the APIs... 

Regards,
Simon

Jaco Naude

unread,
Jan 31, 2013, 12:05:46 AM1/31/13
to qtil...@googlegroups.com
Hi Simon

It should be doable by the object pool, however the access functions might need to be added.

When adding an object to the object pool it gets assigned an unique ID. This is stored in  property on the object called Qtilities::Core::Properties::qti_prop_OBSERVER_MAP. You can get the property as described in its documentation. To find the object with the given ID easily needs to be added. If you file a request on Github for that I will add it.

Will this work for you?
Cheers
Jaco




--
--
To post to this group, send email to qtil...@googlegroups.com
To unsubscribe from this group, send email to
qtilities+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/qtilities?hl=en?hl=en
 
---
You received this message because you are subscribed to the Google Groups "Qtilities" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qtilities+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Jaco Naude'

Qtilities: Building blocks for Qt applications.

Simon Gemmell

unread,
Jan 31, 2013, 11:32:03 PM1/31/13
to qtil...@googlegroups.com
Seems complicated and looks like it works on an Observer. I wrote one myself which does the job quite nicely in 20 minutes. Might be overengineering to use OBJECT_MANAGER for this?

Was just looking for something like this:

OBJECT_MANAGER->RegisterObject(myQObjectPtr, myQObjectId);
and then
myQObjectPtr = OBJECT_MANAGER->Object(myQObjectId);

I'm actually surprised the QApplication doesn't have something like this.

Regards,
Simon
Reply all
Reply to author
Forward
0 new messages