[Qt-interest] Signal-slot routing in a complex GUI
Pavel Zdenek
pavel.zdenek at gmail.com
Mon May 10 15:01:09 CEST 2010
Hello Qters,
i consider myself a qt apprentice, not so rookie, got some scars and
Qt source digging behind me already. But there is one thing which i am
most probably doing wrong: consider a moderately complex GUI
application. The QMainWindow dependence tree has two or more fairly
long branches, where the signal source is down in one and the target
slot is in another. Let's say an QMdiArea with a QDockWidget. One
branch is QDockWidget>QVBoxLayout>list of custom QWidgets>row of
QCheckBoxes. Another branch is a
QMdiSubWindow>QTabWidget>QGridLayout>QButton. I want to disable some
checkboxes with a button click(). How would you do that?
For me, it always resulted in tons of boilerplate signals and slots
everywhere, which single purpose is to route the event up and down.
It's hard to manage because of the myriad of connect() calls
everywhere, and on the way it pollutes the container classes which do
not care at all. Connecting signals to signals helps a little bit, but
you just reduce the mess, not solving it.
I started thinking about some sort of singleton router, which would
act as a repository and a switchboard for any source/target which opts
in. But given the total lack of any such existing solution (not even
blog about needing some), i suspect it not being The Right Way (TM). I
see DBus as way too heavy for such purposes.
Regards,
Pavel Z.
More information about the Qt-interest-old
mailing list