[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] Many Sources for a Signal
From:       Andreas Pakulat <apaku () gmx ! de>
Date:       2011-02-27 22:25:35
Message-ID: 20110227222535.GD7144 () barmbek
[Download RAW message or body]

On 27.02.11 19:06:37, Nahuel Defossé wrote:
> Hi,
> 
> we're working in a tabed text editor which uses QtGui's QTabWidget to
> display a QPlainText edit for each tab.
> We needed to enable or disable some menus depending on the QTextEditor
> activity and some other
> widgets surrounding the tab widget also need to be updated (for
> example, the status bar displays the line
> and column number the text cursor is currently placed at).
> To obtain a generic way to publish events within the text editor
> without knowing possible receivers, we
> hacked QApplication.notify method [1] to notify every possible widget
> receiving that an event signature in the
> widget hierarchy chain stopping at the QMainWindow instance.
> 
> In a few words, multiple sources need to send an event to unknown
> receivers, but these events have to
> be in the context of the QMainWindow widget hierarchy. What do you suggest?

Create a class that is central to your application that each part can
access. That class has notifyXYZ functions and emits signals. Then any
component can register to the signals its interested in and the
components that want to trigger the signals can use the notify functions
to notify all receivers. Hacking QApplication is not necessary for this.

Andreas

-- 
While you recently had your problems on the run, they've regrouped and
are making another attack.
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic