[Qt-interest] Signal-slot routing in a complex GUI

BRM bm_witness at yahoo.com
Mon May 10 15:20:23 CEST 2010


Pavel,

There's not quite enough information to figure out what you are doing.
And depending on what you are doing, there are different solutions.

For example, if you stuff it trying to manage a data set, then it may be better to use the Model/View architecture, and use one model for each data set, even with multiple viewers/editors.
On the other hand, you may need to use QSignalMapper, or you may just need to institute a level of signal/slot abstraction and/or layer you widgets a bit.

For example:
- having the main window have the signals/slots you need and then connecting the widgets to those instead of directly to the other widgets.
- Create a custom widget that contains a series of widgets inside; reducing the number of widgets instantiated by the main window

Typically, for any complex GUI you will need to at least reduce the number of widgets in the main window by creating widgets that perform specific functionality, providing widgets in themselves as needed.
For example, any time I do a QDockWidget, it's its own object derived from QDockWidget that the main window then instantiates; for sub-windows of QMdiArea same thing but you can derive directly from QWidget. (I think you can possibly do that with QDockWidget too; though I find it simpler to just subclass QDockWidget.)

Any how, you need to provide some more details.

HTH,

Ben





________________________________
From: Pavel Zdenek <pavel.zdenek at gmail.com>
To: qt-interest at trolltech.com
Sent: Mon, May 10, 2010 9:01:09 AM
Subject: [Qt-interest] Signal-slot routing in a complex GUI

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.
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100510/76a4709b/attachment.html 


More information about the Qt-interest-old mailing list