Results 1 to 7 of 7

Thread: Is there a way to know when an object's objectName() changes?

  1. #1
    Join Date
    Aug 2008
    Posts
    132
    Thanks
    23
    Thanked 3 Times in 3 Posts

    Default Is there a way to know when an object's objectName() changes?

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Is there a way to know when an object's objectName() changes?

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    JPNaude (14th August 2009)

  4. #3
    Join Date
    Feb 2009
    Posts
    11
    Qt products
    Platforms
    Unix/X11 Windows
    Thanks
    4

    Exclamation Re: Is there a way to know when an object's objectName() changes?

    Why don't you subclass and implement the method yourself? Then you can emit a signal when it's called.

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Is there a way to know when an object's objectName() changes?

    Quote Originally Posted by nimaweb View Post
    Why don't you subclass and implement the method yourself
    Because QObject::setObjectName() is not virtual.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. The following user says thank you to wysota for this useful post:

    nimaweb (14th August 2009)

  7. #5
    Join Date
    Aug 2008
    Posts
    132
    Thanks
    23
    Thanked 3 Times in 3 Posts

    Default Re: Is there a way to know when an object's objectName() changes?

    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

  8. #6
    Join Date
    Jul 2008
    Location
    London, UK
    Posts
    11
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 5 Times in 5 Posts

    Default Re: Is there a way to know when an object's objectName() changes?

    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:
    1. void QObject::setObjectName(const QString &name)
    2. {
    3. Q_D(QObject);
    4. d->objectName = name;
    5. }
    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.

  9. The following user says thank you to burnttoy for this useful post:

    JPNaude (17th August 2009)

  10. #7
    Join Date
    Aug 2008
    Posts
    132
    Thanks
    23
    Thanked 3 Times in 3 Posts

    Default Re: Is there a way to know when an object's objectName() changes?

    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

Similar Threads

  1. QWizard creating objects dynamically
    By afflictedd2 in forum Qt Programming
    Replies: 5
    Last Post: 24th March 2009, 16:43
  2. objects modelling
    By mickey in forum General Discussion
    Replies: 1
    Last Post: 12th April 2008, 09:14
  3. Ole objects in Qt(MS OFFice)
    By mchara in forum Qt Programming
    Replies: 9
    Last Post: 26th September 2007, 08:07
  4. Custom objects in a QGraphicScene
    By draand in forum Qt Programming
    Replies: 2
    Last Post: 24th July 2007, 12:31
  5. static objects in libraries
    By Rawk in forum Qt Programming
    Replies: 3
    Last Post: 16th January 2007, 20:03

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.