Results 1 to 8 of 8

Thread: reacting to changes for non-QObject classes?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2010
    Posts
    63
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: reacting to changes for non-QObject classes?

    im not quite sure i know what you meant.. who has whom?
    anyhow, say i post an event - who is the receiver? will it reach the rest of the gui if i send it to the main window?

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

    Default Re: reacting to changes for non-QObject classes?

    Quote Originally Posted by jajdoo View Post
    im not quite sure i know what you meant.. who has whom?
    You can look into Qt's source code but I suspect it's something like this:

    Qt Code:
    1. class Watcher;
    2. class Object {
    3. private:
    4. QList<Watcher*> m_watchers;
    5. friend class Watcher;
    6. void notify();
    7. };
    8. class Watcher : public QObject {
    9. Q_OBJECT
    10. public:
    11. Watcher(Object *obj, QObject *parent = 0) : QObject(parent) { obj->m_watchers << this; }
    12. signals:
    13. void objectChanged(Object*);
    14. friend class Object;
    15. };
    16.  
    17. void Object::notify() {
    18. foreach(Watcher *w, m_watchers) emit w->objectChanged(this);
    19. }
    To copy to clipboard, switch view to plain text mode 

    anyhow, say i post an event - who is the receiver?
    Every object that wanted to receive notifications.

    will it reach the rest of the gui if i send it to the main window?
    No, unless each interested object installs an event filter on the main window object.
    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:

    jajdoo (9th August 2011)

Similar Threads

  1. Replies: 2
    Last Post: 18th June 2013, 10:31
  2. reacting on moving or resizeing
    By WilliamSpiderWeb in forum Newbie
    Replies: 3
    Last Post: 3rd March 2011, 21:45
  3. Replies: 9
    Last Post: 26th October 2009, 00:13
  4. Inherit from QObject for data-classes?
    By niko in forum Qt Programming
    Replies: 7
    Last Post: 14th July 2007, 15:09
  5. Replies: 1
    Last Post: 13th July 2006, 21:10

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.