
Originally Posted by
jajdoo
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:
class Watcher;
class Object {
private:
QList<Watcher*> m_watchers;
friend class Watcher;
void notify();
};
Q_OBJECT
public:
Watcher
(Object
*obj,
QObject *parent
= 0) : QObject(parent
) { obj
->m_watchers <<
this;
}signals:
void objectChanged(Object*);
friend class Object;
};
void Object::notify() {
foreach(Watcher *w, m_watchers) emit w->objectChanged(this);
}
class Watcher;
class Object {
private:
QList<Watcher*> m_watchers;
friend class Watcher;
void notify();
};
class Watcher : public QObject {
Q_OBJECT
public:
Watcher(Object *obj, QObject *parent = 0) : QObject(parent) { obj->m_watchers << this; }
signals:
void objectChanged(Object*);
friend class Object;
};
void Object::notify() {
foreach(Watcher *w, m_watchers) emit w->objectChanged(this);
}
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.
Bookmarks