[Qt-interest] class composition & communication in Qt

Frederico A. M. Prado famprado at terra.com.br
Thu Sep 30 07:15:07 CEST 2010


If it is not too much information and the MainWindow knows when he widget  
will need the information you could use  a signal from the main window  
connected to a slow in the widget.

If the MainWindow does not know when to send to information you can  
request the information in the same way, linking a signal from the widget  
to a slot in mainwindow.

The MainWindow can do both connections when it creates the widget. As far  
as I know that is the usual pattern in QT.

If you have to transfer a lot of information, on the other hand, other  
approaches could be better. You could keep the request as a signal/slot,  
but implement a public function in your widget class which accepts the  
data from when called from the MainWindow, for example.



On Wed, 29 Sep 2010 11:48:05 -0300, pmqt71 <pmqt71 at gmail.com> wrote:

> Hi all,
>
> I have a MainWindow and a widget member class.
>
> The widget,  while painting, needs information from MainWindow. So what  
> is
> the best way to access information from the member class to the holding
> class? Is there an usual pattern in Qt or GOF for this problem?
>
> thanks
> pm



More information about the Qt-interest-old mailing list