Hi
Is there a way to know when setObjectName() is called on an object? I couldn't find a signal or event related to this. Thus, is there a clever way to know this?
Thanks,
Jaco
Hi
Is there a way to know when setObjectName() is called on an object? I couldn't find a signal or event related to this. Thus, is there a clever way to know this?
Thanks,
Jaco
As far as I remember there is an internal event that gets posted to the widget but it's not in the API. But I'm not sure if I'm right - you'd have to check in the sources of QObject.
JPNaude (14th August 2009)
Why don't you subclass and implement the method yourself? Then you can emit a signal when it's called.
Because QObject::setObjectName() is not virtual.
nimaweb (14th August 2009)
Thanks for the responses. Apart from the fact that setObjectName() is not virtual, I want to be able to monitor any QObject based class, thus a subclass wouldn't have done the job even if it was virtual.
I have not had time to look at the sources yet, but will do so.
Thanks for the help.
Jaco
Hiya, I just looked at the sources for 4.5.2 and I'm afraid I can't find any emitted signal. The code for QObject::setObjectName is simply...
Qt Code:
{ d->objectName = name; }To copy to clipboard, switch view to plain text mode
No internal event, no signal. Ho hum. I'm afraid I've got no solutions for you beyond adding this feature to Qt yourself. This is quite do-able but you'll be stuck with a version of Qt source differing from the release versions which could prove to be a maintenance problem for you. If this is just for debugging then you'll probably get away with it.
JPNaude (17th August 2009)
Hi
Thanks for checking it, I didn't get to it yet.
I'll have to make another plan then, I really need this. I'll perhaps use my own dynamic property then since there is a signal which is emitted when dynamic properties change.
Thanks again,
Cheers
Bookmarks