[Qt-interest] Basic non modal dialog question

Phil phillor at telstra.com
Thu Feb 18 02:43:13 CET 2010


On Wed, 17 Feb 2010 03:17:32 pm Ellen Kestrel wrote:
> This is what the slot/signal connecting functions are designed for. 
>  Declare all of your dialogs (as pointers) as members in the main
>  application class, and then use connect to connect signals from those
>  dialogs to slots in the main application class (or to slots in other
>  dialog classes).  Then create signals in the dialogs that fire when the
>  user does something you want to take note of.  In fact, if you do all the
>  connecting in the constructor of the main class, you probably don't even
>  have to save persistent pointers to the dialogs at all.
> 

Thank you Ellen for your helpful reply. I understand how to create and 
connect to a member dialog but I thought a dialog as a separate class was 
the preferred method? Maybe not in this instance?

John's reply, has me intrigued and may lead to an answer to a long standing 
difficulty.

> ??!!   Of course signals and slots work across classes. 

Take this code for instance:

connect(action_OpenMyDialog, SIGNAL(triggered()), this, 
SLOT(showDialog()));

This works if showDialog() is a member of the class that sends the signal 
but how do I write code where the showDialog() slot is a member of a 
different class?

-- 
Regards,
Phil



More information about the Qt-interest-old mailing list